title: How to change scene when button is pressed using Sprite Kit and swift 2
body: <p>I am new to swift and trying add some extra features after reading this tutorial <a href="http://www.raywenderlich.com/66877/how-to-make-a-game-like-candy-crush-part-1" rel="nofollow">http://www.raywenderlich.com/66877/how-to-make-a-game-like-candy-crush-part-1</a>. What I want to do is combine with the element of digital pets, kind like the iOS game 'Best Friend'. So first, I add a main scene(<a href="http://i.stack.imgur.com/qfh3K.png" rel="nofollow">picture of main scene</a>) and several buttons, when button is pressed, the scene would change. Below are the codes I used to achieve it.
  MainSceneController.swift:</p>
  
  <pre><code>import UIKit
  import SpriteKit
  
  class MainSceneController: UIViewController {
  
      @IBOutlet weak var settingButton: UIButton!
      @IBOutlet weak var storeButton: UIButton!
      @IBOutlet weak var petsButton: UIButton!
      @IBOutlet weak var levelButton: UIButton!
  
      override func prefersStatusBarHidden() -&gt; Bool {
          return true
      }
  
      override func shouldAutorotate() -&gt; Bool {
          return true
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let mainScene = MainScene(size:CGSize(width: 320, height: 568))
          let skView = self.view as! SKView
          skView.showsFPS = true
          skView.showsNodeCount = true
          skView.ignoresSiblingOrder = true
          mainScene.scaleMode = .AspectFill
          skView.presentScene(mainScene)
      }
  
      @IBAction func changeScene(sender: UIButton) {
          let labelText = sender.titleLabel?.text!
          print(labelText)
          switch (labelText!) {
              case "LevelButton":
                  let scene = LevelScene(size:CGSize(width: 320, height: 568))
                  let reveal = SKTransition.fadeWithDuration(1)
                  scene.scaleMode = SKSceneScaleMode.AspectFill
                  scene.view?.presentScene(scene, transition: reveal)
              case "PetsButton":
                  let scene = PetsScene(size:CGSize(width: 320, height: 568))
                  let reveal = SKTransition.fadeWithDuration(1)
                  scene.scaleMode = SKSceneScaleMode.AspectFill
                  scene.view?.presentScene(scene, transition: reveal)
              default:
                  break
          }
  
      }
  
  }
  
  import SpriteKit
  
  class PetsScene: SKScene {
  
      override init(size: CGSize) {
      super.init(size: size)
      }
  
      required init(coder aDecoder: NSCoder) {
          fatalError("init(coder:) has not been implemented")
      }
  
      override func didMoveToView(view: SKView) {
          backgroundColor = SKColor.redColor()
          let mylabel = SKLabelNode(fontNamed: "Chalkduster")
          mylabel.text = "PetsScene"
          mylabel.fontSize = 70
          mylabel.position = CGPoint(x: self.frame.size.width / 2, 
                                     y: self.frame.size.height / 2)
          self.addChild(mylabel)
      }
  
  }
  </code></pre>
  
  <p>When I pressed the button, the scene do not change. I also use segue to achieve it. But is seems like not what I want. And I have looked for some projects source code, but I cannot find similar one. I would appreciate any advice, thanks in advance.</p>