0

Hey all I have a Spritekit animation that I want to trigger when the user wins the level. This is what I have

 if([[other name] isEqualToString:@"win"])
{
    NSLog(@"WE HAVE WON THE LEVEL");

    [bomb removeFromParent];

    [self saveUserInfo];

    [[self view] performSelector:@selector(presentScene:) withObject:[LevelSelectScene scene] afterDelay:2];
}

How should I approach triggering the animation right after the bomb is removed from the parent?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
user3411711
  • 55
  • 1
  • 2
  • 7
  • Don't use performSelector:afterDelay: in Sprite Kit. Read this: http://stackoverflow.com/a/23978854/201863 Then use Actions, you can then use the runAction's completionBlock or the runBlock action. – CodeSmile Nov 06 '14 at 18:15
  • Sorry I am so new and still learning at this, how would my code look by switching it with the one in the example you have given? – user3411711 Nov 06 '14 at 18:22

1 Answers1

0
- (void)gameOver
{
    [self runAction:[SKAction sequence:@[[SKAction runBlock:^{
        [bomb removeFromParent];
        [self yourAnimation];
        [self saveUserInfo];
    }] ,[SKAction waitForDuration:yourDelay], [SKAction runBlock:^{
        GameOverScene *gameOverScene = [GameOverScene sceneWithSize:self.size];
        [self.view presentScene:gameOverScene transition:[SKTransition pushWithDirection:SKTransitionDirectionLeft duration:0.5]];
    }]]]];
}
Valar Morghulis
  • 916
  • 1
  • 9
  • 26