我想实现一个菜单场景,然后在新场景中启动游戏。以下是我的解决方案,但我想知道这是否是达到预期效果的首选方式,或者是否有其他人有任何替代方案。
GameScene.swift
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let gameScene = MainGameScene(fileNamed: "MainGameScene")
gameScene?.initMenuScene(self)
let transition = SKTransition.doorwayWithDuration(1.0)
self.view?.presentScene(gameScene!, transition: transition)
}
MainGameScene.swift
class MainGameScene: SKScene
{
var menuScene: SKScene?
func initMenuScene(scene: SKScene)
{
self.menuScene = scene
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let transition = SKTransition.doorwayWithDuration(1.0)
self.view?.presentScene(menuScene!, transition: transition)
}
}