2014-11-06 142 views
0

嘿所有我有,我想,當用戶贏得水平,觸發Spritekit動畫。這就是我所擁有的觸發spritekit動畫

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]; 
} 

我應該如何在從父母移除炸彈後立即觸發動畫?

+0

不要在Sprite Kit中使用performSelector:afterDelay:。閱讀:http://stackoverflow.com/a/23978854/201863然後使用Actions,然後可以使用runAction的completionBlock或runBlock操作。 – LearnCocos2D 2014-11-06 18:15:26

+0

對不起,我很新,仍然在學習這個,我的代碼如何通過在你給出的例子中切換代碼來查看? – user3411711 2014-11-06 18:22:14

回答

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]]; 
    }]]]]; 
}