我创建了一个包含3个场景的游戏(1.mainMenu,2.Settings,3.gameScene)。我无法解决每次点击homeButton时出现的错误(从“设置”场景返回到mainMenu)切换场景和应用程序崩溃。 我在另一个场景中使用相同的原理(从gameScene到mainMenu)并且它运行良好,但为什么不在另一个场景中呢?
错误:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
这里是设置场景:
class Settings: SKScene{
let backToMenuButton = SKSpriteNode(imageNamed: "BlackArrow1.0")
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches{
let locationUser = touch.location(in: self)
if atPoint(locationUser) == backToMenuButton {
let transition = SKTransition.crossFade(withDuration: 0.2)
let mainMenu1 = mainMenu(size: self.size)
self.view?.presentScene(mainMenu1, transition: transition)
}
}
}
}