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 override func didMoveToView(view: SKView) { addChildToScene(); } //#5 func addChildToScene() { PlayButton.zPosition = 1 Background.zPosition = 0 Background.size = CGSize(width:self...