我试图在 SKAction
出现后删除我的 shootA SKSpriteNode
,但如果我这样做,它似乎会在操作之前触发。
提交一次后如何删除?
这是我的代码:
SKTexture* shootTexture1 = [SKTexture textureWithImageNamed:@"shoot-b"];
shootTexture1.filteringMode = SKTextureFilteringNearest;
SKTexture* shootTexture2 = [SKTexture textureWithImageNamed:@"shoot-a"];
shootTexture2.filteringMode = SKTextureFilteringNearest;
SKAction* flap = [SKAction repeatAction:[SKAction animateWithTextures:@[shootTexture1, shootTexture2, ] timePerFrame:0.1] count:1];
SKSpriteNode *shootA = [SKSpriteNode spriteNodeWithTexture:shootTexture1];
[shootA setScale:1.0];
shootA.position = CGPointMake(dragon.position.x+40, dragon.position.y-10);
shootA.size = CGSizeMake(shootA.size.width/8, shootA.size.height/8);
[shootA runAction:flap withKey:@"shootGo"];
[self addChild: shootA];
最佳答案
您可以将 SKAction 更改为序列,然后将 removeFromParent
添加到末尾 -
SKAction* flap = [SKAction sequence:@[
[SKAction repeatAction:[SKAction animateWithTextures:@[shootTexture1, shootTexture2, ] timePerFrame:0.1] count:1],
[SKAction removeFromParent]
]];
关于ios - 在 SKAction 之后移除 FromParent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23438991/