What Im Doing:
I have bombs being set every few seconds through a repeating Timer, continuously calling the following method.
//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];
}
What I want:
Is after the animation is over for the next sprite(explosion sprite) to appear in the location of where the bomb was.
The Problem:
There is no action I see to replace the sprite or aid in what I'm trying to do. SKAction Class Reference But I do see this task customActionWithDuration:actionBlock: but have no idea how to use it nor can find any examples through searches.
The Question:
Can someone show me how to use create this task to replace my bomb sprite with my explosion sprite after the 5 second bomb sprite animation is over? Thank you