Search code examples
swiftsprite-kitscene

SpriteKit Scene order


I'm creating a game using Sprite Kit. I have my GameScene and GameOverScenenow I want to create a MenuScene Where do I control the order of the MenuScene so that it shows up after LaunchScene

class GameViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    if let scene = GameScene.unarchiveFromFile("MenuScene") as? GameScene {
        // Configure the view.
        let skView = self.view as! SKView

        skView.ignoresSiblingOrder = true

        scene.scaleMode = .AspectFill

        skView.presentScene(scene)
    }
}

Edit tried putting ("MenuScene") as the scene but when I run the game that scene won't show


Solution

  • Ok so I found out that I was one the right path. I just needed to change this line. Instead of this
    if let scene = GameScene.unarchiveFromFile("MenuScene") as? GameScene { add this if let scene = MenuScene.unarchiveFromFile("MenuScene") as? MenuScene {