Sprite kit 呼叫期间暂停游戏

Sprite kit 呼叫期间暂停游戏,sprite-kit,appdelegate,Sprite Kit,Appdelegate,在哪里可以处理来电时暂停游戏的代码。我知道 -(void)applicationWillResignActive:(UIApplication *)application 但在游戏中,我如何调用它(我不能从SKScene调用它,也不能从view controller调用它-只能从app delegate调用,但我如何从那里运行属于view controller的代码) 谢谢。与此同时,我发现了它,我使用了NSNotification,这是一行代码,将它放在view controller中,您要

在哪里可以处理来电时暂停游戏的代码。我知道

-(void)applicationWillResignActive:(UIApplication *)application
但在游戏中,我如何调用它(我不能从SKScene调用它,也不能从view controller调用它-只能从app delegate调用,但我如何从那里运行属于view controller的代码)


谢谢。

与此同时,我发现了它,我使用了NSNotification,这是一行代码,将它放在view controller中,您要处理它:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pauseGame) name:UIApplicationWillResignActiveNotification object:nil];