11

I'd like to create a pause menu but I don't know the simplest way to do this... I think a simple way would be to pause all my SKActions, but I couldn't find any method in the reference. Thanks for help.

2 Answers 2

13

Documentation says that parent SKView object has a paused property. Set it to YES to pause the scene.

Paused

A Boolean value that indicates whether the view’s scene animations are paused.

@property(getter=isPaused, nonatomic) BOOL paused

Discussion If the value is YES, then the scene’s content is fixed on screen. No actions are executed and no physics simulation is performed."

//the parent SKView
spriteView = (SKView *) self.view;

//pause button
-(IBAction)goPauseButton {
    if(!spriteView.paused){
        spriteView.paused = YES;
    }else{
        spriteView.paused = NO;
    }
}
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your help! :) Your are right. All the animations and actions stop. But if i set the paused property back to no, the sprite move on where they would be if the view would have never get paused. Any idea why? :)
The pausing works fine for me, can you post your code showing how and where you call it?
I know what the problem of my code is... I use the current time from the update: method and the current time does logically not stop. So I have to fix that.
Do you have any Idea how I can fix that?
Thanks for your help.. I fixed it ;) It was a problem of my code.
10

You can also pause all the SKActions by setting the speed of the scene to zero-- this means that all the actions will stop, and you do not need to worry about them moving to where they would not have been if you did not pause

self.speed = 0;

easy as that

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.