snksnk
snksnk

Reputation: 1595

Sprite kit does not resume after pausing

My game uses physics and I do pause it successfully but I cannot resume it. The nodes are actually falling objects and when pausing they stay in air and all the physics is gone as expected when pausing a scene. But when I resume they stay in air and do not drop nor I can see any sort of physics being resumed. Any advise would be appreciated. Here is what I use:

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

Upvotes: 0

Views: 378

Answers (1)

CodeSmile
CodeSmile

Reputation: 64478

I condensed the code. Maybe you can spot the mistake. ;)

self.scene.paused = YES;

self.scene.view.paused = NO;

Upvotes: 2

Related Questions