# How to pause and unpause the Particular action of a sprite?

My game has a sprite representing a character. When the character picks up an item, the sprite should stop moving for a period of time.

I use CCbezier to make the sprite move, like this:

sprite->runaction(x)


Now I want the sprite to stop its current action (moving) and later resume it. I can make the sprite stop by using:

sprite->stopaction(x)


but if I do that, I can't resume the movement. How can I do that?

You could try this:

[yourSprite pauseSchedulerAndActions]


and to resume

[yourSprite resumeSchedulerAndActions]


If that shouldn't work, another option might be:

//pause
[sprite.actionManager pauseTarget:sprite];

//resume
[sprite.actionManager resumeTarget:sprite];

• [yourSprite pauseSchedulerAndActions] and to resume [yourSprite resumeSchedulerAndActions] These code pause all actions of sprite, i just want pause particular action of sprite, thanks – user1609578 Jun 6 '14 at 1:34

Yes, cocos2d-x has a built in way to do this. If you want to pause everything the character is doing you can simply use:

  _character->pause();

_character->resume();

_scheduler->pauseTarget(_character);

_scheduler->resumeTarget(_character);

• NOTE: this also pauses any actions being performed on the character. If you want to continue the actions, but just pause the animation, do this instead:

• _scheduler is declared in the Node class, so all classes that inherit from it have access to it

.