This has been driving me up the wall! I’m sure that there will be a UBER simple answer, but I just can’t figure it out!
Using CCActionManager, I have paused all actions currently running on the screen successfully. My Question is, how do I get them running again?
P.S, I have tried pauseTarget:self, but it doesn’t stop all the actions currently running for some reason?
Here is my code:
if (backOrNot == NO) {
Pencil = [CCSprite spriteWithFile:@"Pencil.png"];
Pencil.position = ccp(MainChar.position.x, MainChar.position.y + 10);
id action = [CCMoveTo actionWithDuration:3 position:ccp(Pencil.position.x, 550)];
[action setTag:4];
[Pencil runAction:action];
[self addChild:Pencil z:2 tag:4];
NSLog(@"Pencil Shot!");
[[CCActionManager sharedManager] resumeTarget:self];
}
else{
[[CCActionManager sharedManager] pauseAllRunningActions];
}
I am trying to stop all Pencils (Of which there are many) when I go into Pause, or when backOrNot is returned YES.
EDIT:
The problem was SO easy to fix; my point was to get a pause to work. For all of those wondering, you do this:
[[CCDirector sharedDirector]pause];
You’re correct, there’s a simple answer! 🙂
Pausing all actions returns a NSMutableSet with the paused actions:
Later you can unpause those paused actions from the set:
Make sure to use a strong reference for (non-ARC: retain) pausedActions and nil (non-ARC: release and nil) pausedActions after resume. The set’s contents are only valid until the actions are resumed, if you keep the set the actions won’t deallocate after they’ve completed.
pauseTarget:self will work, it’s what the CCNode class is using if you run [self pauseSchedulerAndActions] and that definitely works.