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?
Asked
Active
Viewed 328 times
1 Answers
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
-
sorry it was a general question. i solved by simply dismissing the viewcontroller who was responsible for the scene – Carlo Tarantola May 25 '17 at 05:28