ios - swift-无法呈现 GameViewController 中的第二个场景

标签 ios iphone swift uiviewcontroller sprite-kit

我有两个场景,GameScene 和 PlayScene。我可以展示我的 GameScene,但我无法展示 PlayScene,我使用的是相同的代码和正确的文件名。我正在使用 UIButton 来调用此函数。我什至尝试不调用 showGameScene 而只调用 goToPlayScene 但它仍然不起作用。我正在使用 GameViewController 来呈现这两个场景。

func showGameScene()
{
    if let scene = GameScene(fileNamed:"GameScene") {
        // Configure the view.
        let skView = self.view as! SKView
        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true
        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)
    }
}
func goToPlayScene()
{
    playButton.hidden = true
    Leaderboard.hidden = true

    if let scene = PlayScene(fileNamed:"PlayScene")
    {
        let skView = self.view as! SKView
        /* Sprite Kit applies additional optimizations to improve rendering performance */
        skView.ignoresSiblingOrder = true
        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)
    }

}

最佳答案

您是否创建了 PlayScene.sks 文件?

关于ios - swift-无法呈现 GameViewController 中的第二个场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34867793/

相关文章:

ios - 快速缩放 View Controller

iphone - 有什么方法可以在不获取白色背景的情况下更新 UIWebView 吗?

ios - 如何将旧版本的 iOS SDK 复制到新版本的 Xcode?

iphone - 如何在 Xcode 中使用 cocos2d?

arrays - If 语句查找重复值?

ios - 使用未声明的类型 UITextfield

ios - AVPlayer Live stream 如何获得音频电平计量的电源,新东西?

iphone - 推送的 UIViewController 的 View 总是和全屏一样大

ios - iPad 上的 iPhone 应用程序 : drawViewHierarchyInRect causes glitch

iphone - Cocos2D 弃用的动画方法