user1940136
user1940136

Reputation: 343

Is there a way to pause SKActions?

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.

Upvotes: 11

Views: 3907

Answers (2)

Lucas
Lucas

Reputation: 713

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

Upvotes: 10

AndyOS
AndyOS

Reputation: 3606

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

Upvotes: 13

Related Questions