暂停精灵套件场景


@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。有任何解决这个问题的方法吗?您是否建议我通过重新说明所有代码来将所有场景变成视图?

使用 SKView's isPaused属性:

swift

scene.view?.isPaused = true

目标C

self.scene.view.isPaused = YES;

这将停止所有动作和物理模拟。

使用场景暂停功能

self.scene?.view?.paused = true

属性'暂停'已重命名为'ispaused'

scene?.view?.isPaused = true

最新更新