我有一个泡泡,触摸时会弹出。这个弹出效果可以正常使用下面的代码。但是,当使用覆盖气泡的spritekit粒子效果时,触摸操作不起作用。当粒子效果完成时,触摸动作将起作用。粒子效果是否具有非触摸场?反正在这周围?我试图改变z位置但是没有用。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
SKLabelNode *touchedNode = (SKLabelNode *)[self nodeAtPoint:positionInScene];
if ([[touchedNode name] isEqualToString:@"bubbleBall1"]) {
ballNode.position = bubble1.position;
[_gameNode addChild:ballNode];
[bubble1 removeFromParent];
[self playBubblePopSound];
}
}
这是我在物理接触区使用的粒子效果。
SKEmitterNode *starCollectParticle = [SKEmitterNode emitterNamed:@"starCollect"];
starCollectParticle.position = star1Node.position;
starCollectParticle.zPosition = 0;
//starCollectParticle.particleLifetime = 2;
[self addChild:starCollectParticle];
答案 0 :(得分:0)
这是z.position。我改变了粒子的z位置。这没用。然而,改变SKSpritenode的z.position也是有用的。
-(void)addBubble1:(CGPoint)pos{
gameObjects = [SKTextureAtlas atlasNamed:@"GameObjects.atlas"];
bubble1 = [SKSpriteNode spriteNodeWithTexture:[gameObjects textureNamed:kBubble]];
bubble1.size = bubble1.texture.size;
bubble1.size = CGSizeMake(70,70);
bubble1.position = pos;
bubble1.name = bubble1CategoryName;
**bubble1.zPosition = 1;**
bubble1.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:bubble1.frame.size.width/2];
bubble1.physicsBody.affectedByGravity = NO;
bubble1.physicsBody.dynamic = NO;
bubble1.physicsBody.usesPreciseCollisionDetection = YES;
bubble1.physicsBody.categoryBitMask = bubble1Category;
bubble1.physicsBody.contactTestBitMask = ballCategory | completeObjectNodeCategory | completeObjectBoxNodeCategory;
bubble1.physicsBody.collisionBitMask = completeObjectNodeCategory | lineNodeCategory;
[_gameNode addChild:bubble1];
}
SKEmitterNode *starCollectParticle = [SKEmitterNode emitterNamed:@"starCollect"];
starCollectParticle.position = star1Node.position;
**starCollectParticle.zPosition = 0;**
//starCollectParticle.particleLifetime = 2;
[self addChild:starCollectParticle];