可能有人可以帮我一把......我正在尝试在他们自己的SKCropNodes中添加几个SKEmitterNodes。
我的代码:
// left emitter node
NSString *path = [[NSBundle mainBundle] pathForResource:@"LeftParticle" ofType:@"sks"];
SKEmitterNode *lEmitterNode = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
// left crop node
SKSpriteNode *lMask = [SKSpriteNode spriteNodeWithColor:[UIColor blackColor] size:CGSizeMake(self.size.width/2, self.size.height)];
[lMask setAnchorPoint:CGPointZero];
SKCropNode *lCropNode = [SKCropNode node];
lCropNode.maskNode = lMask;
// move the left emitter under the mask
lEmitterNode.position = CGPointMake(CGRectGetMinX(lMask.frame) + lMask.size.width / 2, self.size.height);
[lCropNode addChild:lEmitterNode];
[self addChild:lCropNode];
// right emitter node
path = [[NSBundle mainBundle] pathForResource:@"RightParticle" ofType:@"sks"];
SKEmitterNode *rEmitterNode = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
// right crop node
SKSpriteNode *rMask = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(self.size.width/2, self.size.height)];
[rMask setAnchorPoint:CGPointZero];
rMask.position = CGPointMake(rMask.size.width, 0);
SKCropNode *rCropNode = [SKCropNode node];
rCropNode.maskNode = rMask;
// move the right emitter under the mask
rEmitterNode.position = CGPointMake(CGRectGetMinX(rMask.frame) + rMask.size.width / 2, self.size.height);
[rCropNode addChild:rEmitterNode];
[self addChild:rCropNode];
这就是结果:
如你所见,我的红色粒子在左侧面具下渲染......为什么?
我试图用以下方法减小面具的大小:
lMask.xScale = lMask.yScale = 0.9;
rMask.xScale = rMask.yScale = 0.9;
这就是结果:
我认为这是渲染缓冲区的问题,或者可能是关于zPosition或bug的问题,或者可能是我真的迷失了。
日Thnx