我的游戏使用了物理,我确实暂停了它,但我无法恢复它。节点实际上是落下的物体,当暂停时它们停留在空气中,并且在暂停场景时所有物理都按预期消失了。但是当我恢复时,他们留在空中并且不会摔倒,也不会看到任何类型的物理恢复。任何建议将不胜感激。这是我使用的:
-(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;
}
答案 0 :(得分:2)
我浓缩了代码。也许你可以发现错误。 ;)
self.scene.paused = YES;
self.scene.view.paused = NO;