iphone - Cocos2d,我忘记了延迟场景的命令是什么

标签 iphone objective-c ios xcode4 cocos2d-iphone

我希望游戏结束场景不会出现几秒钟,这样您就可以真正看到自己是如何死的。我记得不久前做过这件事,但我这辈子都记不起来了。

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

非常感谢。

最佳答案

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

关于iphone - Cocos2d,我忘记了延迟场景的命令是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11665762/

相关文章:

iphone - 是否可以调用带有分机号的电话号码?

iphone - 那么 CALayer 不包含 View 的内容位图?

ios - UITextField 作为它自己的 inputAccessoryView 的 child

iPhone Web 应用程序 - 接听电话时 session 和当前 URL 丢失

代码更新后启用 iOS 8 的设备未收到推送通知

iphone - 注册地址簿更改,使用 ABAddressBookRegisterExternalChangeCallback

ios - 子类 UITabBar 与 UIWebView 一起呈现

ios - 如何向 ios 警报添加操作

iPhone 应用程序在 iPad 上以横向模式打开

ios - 每次从 SwiftUI 中的详细 View 返回时,如何阻止 View 刷新?