0
votes

In my SpriteKit scene I have a pauseView that displays a UIView over the scene, and on the UIView I've created a button in IB to remove the view but when the view disappears, In order to resume the game the user has to hit the pause button a second time. Is there a way to dismiss the view and resume the game?

The pause game method used to display the subview:

-(void)pauseGame {

    if (self.gameIsPaused == NO) {
        [self.view addSubview:pauseView];
        self.gameIsPaused = YES;
        self.scene.view.paused = YES;
    } else {
        self.gameIsPaused = NO;
        self.scene.view.paused = NO;
    }
}

And in the pause layer:

- (IBAction)resume:(id)sender {
    [gameScene pauseGame];
    [self removeFromSuperview];
}
1

1 Answers

0
votes

I think it should be [sender removeFromSuperview];, not self. Assuming "pause layer" is a subclass of a SKNode rather than a UIView subclass.

If that's not it, check if the pause button has been added twice. Ie could have been an accidental copy & paste in IB.