2

我希望游戏结束的场景在几秒钟内不会出现,这样你就可以真正看到你是怎么死的。我记得前一段时间这样做过,但我一生都记不起来了。

        GameOverScene *gameOverScene = [GameOverScene node];
        [gameOverScene.layer.label setString:@"You Lose"];
        [[CCDirector sharedDirector] replaceScene:gameOverScene];         

真的很感激。

4

3 回答 3

1

使用 NSObject[self performSelector:@selector(gameOver) withObject:nil afterDelay:5];并在新方法 GameOver 中替换场景:

- (void)gameOver
{
    GameOverScene *gameOverScene = [GameOverScene node];
    [gameOverScene.layer.label setString:@"You Lose"];
    [[CCDirector sharedDirector] replaceScene:gameOverScene];
}
于 2012-07-26T09:02:00.250 回答
0

一个解决方案可能是安排一个选择器来执行您的操作:

[[CCScheduler sharedScheduler] scheduleSelector:@selector(myMethod:) forTarget:self interval:2.0f paused:[[CCDirector sharedDirector] isPaused]];

和你的方法实现:

- (void)myMethod:(ccTime)dt
{
    [[CCScheduler sharedScheduler] unscheduleSelector:_cmd forTarget:self];

    //your actions here
    GameOverScene *gameOverScene = [GameOverScene node];
    [gameOverScene.layer.label setString:@"You Lose"];
    [[CCDirector sharedDirector] replaceScene:gameOverScene];
}

我希望这有帮助。

于 2012-07-26T09:04:49.017 回答
0

没有得到你真正需要的东西。仍然建议这两个..尝试

[self performSelector:@selector(showGameOverScene) withObject:nil afterDelay:2.0f];

替换为时间:

[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameOverScene scene] withColor:ccWHITE]];
于 2012-07-26T09:05:05.603 回答