0

我正在构建一个游戏。每个场景都有一个主 ViewController 和一个子控制器:开始屏幕和游戏关卡

在启动时,我会展示 StartScreen。然后当按下播放按钮时,我呈现游戏场景(并添加他的控制器)

游戏结束后,我会显示开始屏幕。

问题:开始屏幕没有出现,游戏级别保持不变。

该代码实际上被调用,并且 SKView.scene 包含对右侧的引用(开始屏幕)。但视觉上没有任何变化。

public func gameEnded() {
    print("game ended", skView.scene)
    gameSceneController.willMove(toParent: nil)
    gameSceneController.removeFromParent()
    skView.presentScene(startScene)
    print(skView.scene)
}

但是,如果我向 presentScene 方法添加一个转换参数,一切都会按预期工作......开始屏幕替换游戏场景。

public func gameEnded() {
    print("game ended", skView.scene)
    gameSceneController.willMove(toParent: nil)
    gameSceneController.removeFromParent()
    skView.presentScene(startScene, transition: .crossFade(withDuration: 0.2)) //the ONLY difference in the whole code base
    print(skView.scene)
}

知道可能是什么原因吗?

注意:我目前正在使用 Xcode 11 beta 7

4

0 回答 0