-1

I have a simple game. there are two Viewcontroller. after pressing "play" on the first viewcontroller i have performed a segue to the secondviewcontroller. this secondviewcontroller contains a GADBannerView and a button to stop the game and presents a Gamescene. if the user loses it shows up a new game scene. if the user clicks on the GameoverScene the game restarts. I would like to to perform a segue after the user press on the button and i would like to go back to the first Viewcontroller. I've made it in the storyboard. the problem is that the game doesn't stop. (i know it because i have a background music) and once i'm in the first viewcontroller if I click again "play" the game doesn't work as it should. i've figured that the problem occurs when i click the "back button". how can I dismiss the game scene and go back to the first viewcontroller?

1 Answers1

1

There's no way to tell what your problem is, because you didn't post any code, but you can try something like this to dismiss your Game Scene:

self.view?.presentScene(nil) // From your Game Scene!

I have a game, and I use a method that does that job, and it looks something like this:

class GameScene : SKScene {

    // ...

    func dismiss() {
        self.removeAllActions()
        self.removeAllChildren()
        self.removeFromParent()
        self.view?.presentScene(nil)
    }

    // ...

}

After that, call the method that will present your ViewController! Hopefully that's useful for you!

ThiagoAM
  • 1,432
  • 13
  • 20