Present the Title Scene
Apple Game Frameworks and Technologies — by Tammy Coron (141 / 193)
👈 Add New Scenes | TOC | Load the First Game Scene 👉
You’ve already seen the title scene for Val’s Revenge, now it’s time to let the player see it. For that to happen, you’ll need to make some adjustments to the existing code.
Switch to the GameViewController.swift file and update the viewDidLoad() method to match this:
override func viewDidLoad() {
super.viewDidLoad()
// Create the view
if let view = self.view as! SKView? {
// Create the scene
let scene = TitleScene(fileNamed: "TitleScene")
// Set the scale mode to scale to fill the view window
scene?.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
// Set the view options
view.ignoresSiblingOrder = false
view.showsPhysics = false
view.showsFPS = false
view.showsNodeCount = false
}
}
With this update, instead of loading the game scene as the initial scene, you’re now loading the title scene. Before you build and run the project, let’s get the first game scene working, too.
👈 Add New Scenes | TOC | Load the First Game Scene 👉
Apple Game Frameworks and Technologies by Tammy Coron can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.