CCAnimation *animation = [CCAnimation animationWithName:@"fly" delay:0.6f frames:animFrames];
id animationAction = [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO];
id actionTo = [CCMoveTo actionWithDuration:12 position: ccp(400, 200)];
[sprite runAction: [CCRepeatForever actionWithAction: animationAction] ];
[sprite runAction: actionTo ];
I want stop animation when actionTo is finished. How can i do?
Stop animation when actionTo is finished?
(9 posts) (6 voices)-
Posted 2 years ago #
-
You can sequence actionTo with CallFunc action at the end, and then do whatever you need in CallFunc's selector method, including stopping actions on sprite
Posted 2 years ago # -
or you can run action with tag and the check if getActionByTag returns something different than null
Posted 2 years ago # -
@crmagicxxx, including stopping actions on sprite
How can i stop actions on sprite?Posted 2 years ago # -
[mySprite runAction:[CCSequence actions:myAction,[CCCallFuncN actionWithTarget:self selector:@selector(stopAction)],nil]]; ... -(void)stopAction { [mySprite stopAllActions]; }Posted 2 years ago # -
or you can specify which action you'd like to stop - with tag, again ;)
[mySprite stopActionByTag:tag];
Posted 2 years ago # -
I don't understand this:
[mySprite runAction:[CCSequence actions:myAction,[CCCallFuncN actionWithTarget:self selector:@selector(stopAction)],nil]]; ... -(void)stopAction { [mySprite stopAllActions]; }Let me try to translate the above code. You use CCSequence to call stop action after 'myAction' finish its action but did the action stop at first time because CCSequence will not execute the method of "-(void)stopAction" unless myAction finished its action right?
If I have so many sprite running on my scence simultaneously (imagine a character with hand, weapon, all moving) . And I want the actions immediately stop. How do I do that in simple way?
Posted 1 year ago # -
bump bump.
seem like the action will not stop because of CCSequence..Posted 1 year ago # -
so..i have the same problem.
bump
Posted 1 year ago #
Reply
You must log in to post.