@property (SK_NONATOMIC_IOSONLY, getter = isPaused) BOOL paused;
我发现这行代码可以添加到我的项目中,我将如何暂停整个游戏?
例如:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches)
{
SKSpriteNode *pause = (SKSpriteNode*)[self childNodeWithName:@"pause"];
CGPoint location = [touch locationInNode:self];
// NSLog(@"** TOUCH LOCATION ** \nx: %f / y: %f", location.x, location.y);
if([pause containsPoint:location])
{
NSLog(@"PAUSE GAME HERE SOMEHOW");
}
}
}
如您所见,我已经设置了按钮。当我选择它时,我将如何暂停整个场景?然后当有人点击恢复按钮时恢复它。
好的,所以我有一些建议可以打电话
self.scene.view.paused = YES;
除了这是问题,在我的应用程序委托中
- (void)applicationWillResignActive:(UIApplication *)application{
SKView *view = (SKView *)self.window.rootViewController.view;
view.paused = YES;}
和
- (void)applicationDidBecomeActive:(UIApplication *)application{
SKView *view = (SKView *)self.window.rootViewController.view;
view.paused = NO;
当它实际上是 SKScene 时,我将其设为 SKView 类型。有任何解决这个问题的方法吗?您是否建议我通过重新输入所有代码将所有场景变成视图?