Reputation: 6472
I have a button as a CCMenuItemImage on a menu that I animate to grow and shrink with the code below, however the pauseSchedulerAndActions does not seem to work.
id butActionGrow = [CCScaleTo actionWithDuration:0.8 scale:1.05];
id butActionShrink = [CCScaleTo actionWithDuration:0.8 scale:1.0];
id butActionSeq = [CCSequence actions:butActionGrow, butActionShrink, nil];
[myButton runAction:[CCRepeatForever actionWithAction:butActionSeq]];
[myButton pauseSchedulerAndActions]; //DOES NOT PAUSE ACTION
The animation just continues to run and does not pause. Any thoughts on why it will not pause?
Thanks
EDIT: Note that I need to be able to resume the actions at a later time as well.
EDIT: Based on Karthik Ra's answer below, I came up with the following solution to stop all actions when needed and then when needing to resume the actions, just check to make sure there are no actions already running and start the sequence again:
[myButton runAction:[CCRepeatForever actionWithAction:[CCSequence actions:[CCScaleTo actionWithDuration:0.8 scale:1.05], [CCScaleTo actionWithDuration:0.8 scale:1.0], nil]]];
[myButton stopAllActions];
if ([myButton numberOfRunningActions] == 0) {
[myButton runAction:[CCRepeatForever actionWithAction:[CCSequence actions:[CCScaleTo actionWithDuration:0.8 scale:1.05], [CCScaleTo actionWithDuration:0.8 scale:1.0], nil]]];
}
Upvotes: 0
Views: 296