暂停精灵套件场景

时间:2014-02-06 03:06:18

标签: ios7 sprite-kit skscene skview

@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;

除了这是我的app委托

中的问题
- (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;

我将其设为SKView类型,当它实际上是SKScene时。有任何解决这个问题的方法吗?你是否建议我通过重新输入所有代码来使我的所有场景成为视图?

3 个答案:

答案 0 :(得分:62)

使用SKView的{​​{3}}属性:

<强>夫特

scene.view?.paused = true

目标C

self.scene.view.paused = YES;

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

答案 1 :(得分:2)

使用场景暂停功能

self.scene?.view?.paused = true

答案 2 :(得分:0)

“已暂停”属性已重命名为“ isPaused”

const dateChanged = day => (console.log(day)); //function to call when date changes

inputProps={{
  style: styles.dayPickerInput,
  onChange: event => dateChanged(event.target.value),
}}
相关问题