我创造了一个平台游戏,当我开始游戏时,它直接进入游戏.我希望有一个菜单,其中包含一个启动游戏的按钮和一个可以通往商店的按钮,可以购买不同的背景或角色.如果有人能帮我实现这
class MenuScene: SKScene { override func didMoveToView(view: SKView) { addButtons() } private func addButtons() { // TODO layout buttons here } private func startGame() { let gameScene = GameScene(size: view!.bounds.size) let transition = SKTransition.fadeWithDuration(0.15) view!.presentScene(gameScene, transition: transition) } }
并从您的控制器呈现它:
override func viewDidLoad() { super.viewDidLoad() let sceneView = view as! SKView // sceneView.showsFPS = true // sceneView.showsNodeCount = true sceneView.ignoresSiblingOrder = true scene = MenuScene(size: view.bounds.size) scene.scaleMode = .ResizeFill sceneView.presentScene(scene) }