Configure the View and Load the Scene

In the Project Navigator, select the GameViewController.swift file to open it in the Source Editor. Locate and review the viewDidLoad() method. It looks like this:

 override​ ​func​ ​viewDidLoad​() {
 super​.​viewDidLoad​()
 
 // Load 'GameScene.sks' as a GKScene. This provides gameplay-related content
 // including entities and graphs
 if​ ​let​ scene = ​GKScene​(fileNamed: ​"GameScene"​) {
 
 // Get the SKScene from the loaded GKScene
 if​ ​let​ sceneNode = scene.rootNode ​as!​ ​GameScene​? {
 
 // Copy gameplay-related content over to the scene
  sceneNode.entities = scene.entities
  sceneNode.graphs = scene.graphs
 
 // Set the scale mode to scale to fit the window
  sceneNode.scaleMode ...

Get Apple Game Frameworks and Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.