我有两个场景,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/