When my game enters background mode, I would like to pause completely the game. At the moment this is what I do:
In the AppDelegate:
func applicationWillResignActive(application: UIApplication) {
gameViewControllerDelegate?.pauseGame()
}
In my game controller:
func pauseGame() {
buttonPausePressed(buttonPausePlay)
}
func buttonPausePressed(sender: UIButton!) {
scnView?.scene?.paused = true
stopMusic()
let exampleImage = UIImage(named: "16-play")?.imageWithRenderingMode(.AlwaysTemplate)
sender.setImage(exampleImage, forState: UIControlState.Normal)
}
The method gets called and the image of the button is changed. Even the game is paused. But when I open the app again and un-pause it using:
scnView?.scene?.paused = false
all the graphics changes and other weird things happen. It seems like the SCNActions have never been paused. Any ideas?