在SpriteKit游戏中将segue发布到MainMenu UIViewController之后呈现GameScene

时间:2018-01-08 04:56:56

标签: ios swift sprite-kit

我有一个SpriteKit游戏。在这里,我从UIViewController(GameViewController)呈现GameScene:

class GameViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        var scene: GameScene!

        let  skView = view as! SKView

        skView.isMultipleTouchEnabled = false

        scene = GameScene(size: skView.bounds.size)
        scene.scaleMode = .aspectFill
        skView.presentScene(scene)
        skView.showsPhysics = true
        skView.showsFPS = true

        scene.segueViewController = self
    }

    override var shouldAutorotate: Bool {
        return false
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if UIDevice.current.userInterfaceIdiom == .phone {
            return .allButUpsideDown
        } else {
            return .all
        }
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }
}

只有在我第一次创建GameScene时才能正常工作。游戏结束后,玩家在MainMenu(UIViewController)中重定向。如果我再次尝试呈现GameViewController,我的游戏崩溃了:

错误:

  

libsystem_kernel.dylib`__pthread_kill:         5 - > 0x1110b1fce< + 10>:jae 0x1110b1fd8; 1 + 20 - ;线程1:信号SIGABRT

     

UIKit`UIApplicationMain:

     

47 - > 0x112fb05d6< + 159>:movq 0x116f033(%rip),%rbx; (无效   *)0x0000000111fa9cc0:objc_release线程1:信号SIGABRT

     

12 main:

     

14 - > class AppDelegate:UIResponder,UIApplicationDelegate {Thread   1:信号SIGABRT

     

13开始:

     

libdyld.dylib`start:3 - > 0x115f47d81< + 1>:movl%eax,%edi   线程1:信号SIGABRT

0 个答案:

没有答案