ios - SpriteKit 在暂停后不会恢复

标签 ios objective-c xcode sprite-kit skscene

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

-(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;
}

最佳答案

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

self.scene.paused = YES;

self.scene.view.paused = NO;

关于ios - SpriteKit 在暂停后不会恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24414731/

相关文章:

ios - SwiftUI 如何使用 TabView 隐藏导航栏

ios - 当用户终止应用程序时如何停止 MPMusicPlayerController 播放?

ios - 使用 Xcode Instruments 从内存地址打印对象

ios - swift: UITextField 没有名为 text 的成员

ios - 错误 :socket select() function always returning zero in iOS system

javascript - 如何在 IOS 中更新 App 文件 (html)?

objective-c - 通过引用传递 NSIndexPath

ios - 在 tableViewController 中填充图像

iOS/Xcode : Suppress NSLog Statements for Release in 2018

xcode - Coredata NSFetchRequest DictionaryResultType 空属性 Swift