mardi 4 août 2015

Cannot unpause game when bringing app back to Foreground

My SpriteKit game is automatically paused when the app goes into the background. I'm trying to un-pause the game in the appropriate application events, to no avail. I'm manually un-pausing the two SKViews and the game Scene that constitute the app. From inside the AppDelegate file:

func applicationWillEnterForeground(application: UIApplication) {

    if let vw = self.window?.rootViewController {
        let gc = vw as! GameViewController
        let parView = gc.view as! SKView
        parView.paused = false
        gc.gameView.paused=false
        gc.gameScene.paused=false
        println("paused = \(gc.gameScene.paused)")

    }

}

func applicationDidBecomeActive(application: UIApplication) {

    if let vw = self.window?.rootViewController {
        let gc = vw as! GameViewController
        let parView = gc.view as! SKView
        parView.paused = false

        gc.gameView.paused=false
        gc.gameScene.paused=false
        println("paused = \(gc.gameScene.paused)")

    }

}

At the end I print the pause state. If I hit the device's Home key and then return to the app, it prints false as desired. However, somewhere (not by my code) this is being immediately set back to true, and the game remains paused.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire