通话过程中暂停游戏,打电话和按回家键之间的区别?

当主页button被按下时,我的游戏暂停。 但是,当我接到电话时,它不会。 当游戏激活时,它的行动将会恢复。 打电话和按下HB,我没有区别。 请帮我一下

谢谢。

func pauseGame(){ initResumeButton() pause.removeFromParent() gamePaused = true self.paused = true } func resumeGame(){ resume.removeFromParent() initPauseButton() gamePaused = false self.paused = false } func registerAppTransitionObservers(){ NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillResignActive", name: UIApplicationWillResignActiveNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationDidEnterBackground", name: UIApplicationDidEnterBackgroundNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillEnterForeground", name: UIApplicationWillEnterForegroundNotification, object: nil) } func applicationWillResignActive(){ if !gamePaused && state != .GameStarting{ pauseGame() } } func applicationDidEnterBackground(){ self.view?.paused = true } func applicationWillEnterForeground(){ self.view?.paused = false if gamePaused{ self.paused = true } }