【问题标题】:Sprite kit does not resume after pausingSprite 套件在暂停后不恢复
【发布时间】:2014-06-25 17:11:45
【问题描述】:

我的游戏使用物理,我确实成功地暂停了它,但我无法恢复它。节点实际上是坠落的物体,暂停时它们会停留在空中,并且在暂停场景时所有物理都按预期消失。但是当我恢复时,它们会停留在空中,不会掉落,我也看不到任何类型的物理正在恢复。任何建议将不胜感激。这是我使用的:

-(void) pause{
self.scene.paused = YES;
backgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
[backgroundView setBackgroundColor:[UIColor blackColor]];
[backgroundView setAlpha:.5];

UIImageView *imV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"resume.png"]];
[imV setFrame:backgroundView.frame];
[imV setContentMode:UIViewContentModeScaleAspectFit];
[backgroundView addSubview:imV];
[backgroundView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPause:)]];
[self.view addSubview:backgroundView];


}

-(void) tapPause:(id)sender{

[UIView animateWithDuration:.3 animations:^{
    backgroundView.alpha = 0;
} completion:^(BOOL finished) {
    backgroundView = nil;
    [backgroundView removeFromSuperview];
}];

self.scene.view.paused = NO;
}

【问题讨论】:

    标签: ios objective-c xcode sprite-kit skscene


    【解决方案1】:

    我压缩了代码。也许你能发现错误。 ;)

    self.scene.paused = YES;
    
    self.scene.view.paused = NO;
    

    【讨论】:

    • 很好看!谢谢..我的错!
    • 顺便说一句,你知道这两者有什么区别吗?
    • 我听说暂停视图会暂停更新:消息,暂停只是场景显然会继续接收更新:didSimulatePhyiscs 等消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多