我在做什么:
我每隔几秒就会通过一个重复的计时器设置炸弹,不断调用以下方法。
//in my init method
SKTexture *Bomb5 = [SKTexture textureWithImageNamed:@"Bomb5.gif"];
SKTexture *Bomb4 = [SKTexture textureWithImageNamed:@"Bomb4.gif"];
SKTexture *Bomb3 = [SKTexture textureWithImageNamed:@"Bomb3.gif"];
SKTexture *Bomb2 = [SKTexture textureWithImageNamed:@"Bomb2.gif"];
SKTexture *Bomb1 = [SKTexture textureWithImageNamed:@"Bomb1.gif"];
//SKTexture *explode = [SKTexture textureWithImageNamed:@"explosionnn.gif"];
countdown = [SKAction animateWithTextures:@[Bomb5,Bomb4, Bomb3, Bomb2, Bomb1] timePerFrame:1];
-(void)setBomb{
SKSpriteNode *bombb;
SKSpriteNode *explostionn;
bombb = [SKSpriteNode spriteNodeWithImageNamed:@"Bomb5.gif"];
explosionn = [SKSpriteNode spriteNodeWithImageNamed:@"explosionnn.gif"];
//set bomb in random locations on screen
NSLog(@"Placing Bomb");
int randomYAxix = [self getRandomNumberBetween:0 to:screenRect.size.height];
int randomXAxix = [self getRandomNumberBetween:0 to:screenRect.size.width];
bombb.position = CGPointMake(randomYAxix, randomXAxix);
self.explosion.position = CGPointMake(randomYAxix, randomXAxix);
bombb.size = CGSizeMake(35, 35);
explosionn.size = CGSizeMake(90, 90);
SKAction *removeNode = [SKAction removeFromParent];
//SKAction *changeHeight = [SKAction resizeToHeight:90 duration:0];
//SKAction *changeWidth = [SKAction resizeToWidth:90 duration:0];
SKAction *sequence = [SKAction sequence:@[countdown, removeNode]];
[bombb runAction: sequence];
//add code here that adds the explosion sprite once the sequence has complete
[self addChild:bombb];
}
我想要的是:
在动画结束后,下一个精灵(爆炸精灵)出现在炸弹所在的位置。
问题:
我没有看到任何动作来替换精灵或帮助我正在尝试做的事情。SKAction 类参考 但我确实看到了这个任务 customActionWithDuration:actionBlock: 但不知道如何使用它,也无法通过搜索找到任何示例。
问题:
在 5 秒炸弹精灵动画结束后,有人可以告诉我如何使用创建此任务用爆炸精灵替换我的炸弹精灵吗?谢谢