Reputation: 765
In my game right now I've got a GameScene.swift and a GameOverScene.swift. When the game loads, GameScene.swift shows up and the game plays great. However, now that I'm done with the gameplay, how can I add a start screen that displays when the app opens?
Upvotes: 2
Views: 1182
Reputation: 711
To create the scene that runs when your app first opens, you will have to make some adjustments to the game's view controller. First change
let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene
to
let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! sceneName
and this line in didMoveToView
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
to
if let scene = GameScene.unarchiveFromFile("GameScene") as? sceneName {
This will change the opening scene from GameScene to sceneName, or whatever you called your scene. Also, you must declare you scene like this: class sceneName:SKScene {...}
. You can create a new .swift file (cmd + n) to score this class in for easy file management or you can put it in the GameScene file. Happy coding.
Upvotes: 3