可能有人可以帮我...我正在尝试在他们自己的 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 的问题,或者是一个错误,或者可能是我真的迷路了。
谢谢