在切换到新场景之前,Sprite工具包无法运行动作

时间:2014-03-26 14:52:44

标签: ios sprite-kit skaction

操作不会在此代码中运行:

 SKAction *moveLeft = [SKAction moveToX:(-800) duration:0.6];
 SKAction *moveRight = [SKAction moveToX:(800) duration:0.6];
 [_labelLogo runAction:moveLeft];
 [_labelPlay runAction:moveRight];  

 NewYork *start = [[NewYork alloc] initWithSize:self.size];
 SKTransition *reveal = [SKTransition fadeWithColor:[UIColor clearColor] duration:2];
 reveal.pausesIncomingScene = NO;

 [self.scene.view presentScene: start transition: reveal];

如果我评论NewYork切换他们的工作。

1 个答案:

答案 0 :(得分:3)

问题到行动* moveLeft / * moveRight,它因为立即开始转换到NewYork场景,所以你应该等待* moveLeft / * moveRight完成如下:

 SKAction *moveLeft = [SKAction moveToX:(-800) duration:0.6];
 SKAction *moveRight = [SKAction moveToX:(800) duration:0.6];
 [_labelLogo runAction:moveLeft];

 [_labelPlay runAction:moveRight completion:^{

    NewYork *start = [[NewYork alloc] initWithSize:self.size];
    SKTransition *reveal = [SKTransition fadeWithColor:[UIColor clearColor] duration:2];
    reveal.pausesIncomingScene = NO;

    [self.view presentScene:start transition:reveal];
 }];