O'Reilly logo

iOS Game Development By Example by Samanyu Chopra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the first scene in our game

Now it is time to add a menu scene to our game. For this, select the Platformer folder and right-click on this folder, select New File. Select iOS | Source | Swift File and then Next. Inside Save As, give it the name MenuScene, and click on Create.

Click on your MenuScene.swift file. Now it's time to do some code stuff:

import SpriteKit class MenuScene: SKScene { //#1 let PlayButton: SKSpriteNode let Background: SKSpriteNode //#2 init(size:CGSize, playbutton:String, background:String) { PlayButton = SKSpriteNode(imageNamed: playbutton) Background = SKSpriteNode(imageNamed: background) super.init(size:size) } //#3 required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } //#4 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required