Hi,
I wanted to throw a question out there to see if anyone has thought about this problem (and hopefully has a solution to it). I want to perform a turn animation. Imagine a character that paces back and forth over an unknown distance. Currently, I have animation and movement. I flip the sprite when the movement is to be reversed, so there is no actual turn; the character simply flips instantaneously on the Y-axis. Here's the code:
currentFrameAnimation = [RepeatForever actionWithAction:[Animate actionWithAnimation:animation]];
[self runAction:currentFrameAnimation]; // Run the frame animation
id actionOneWay = [MoveBy actionWithDuration:[self getAnimationDuration:ani] position:ccp(ani->to.x - ani->from.x, ani->to.y - ani->from.y)];
id actionScale = [ScaleBy actionWithDuration: 0.0f scaleX:-1 scaleY:1];
id animationSwim;
currentMovementAnimation = [RepeatForever actionWithAction: [Sequence actions:actionOneWay,
[DelayTime actionWithDuration:ani->delay],
actionScale,
[actionOneWay reverse],
[DelayTime actionWithDuration:ani->delay],
[actionScale reverse],
nil]];
[self runAction:currentMovementAnimation]; // Run the movement animation
I may be answering my own question here, but my thought is to combine these two actions using Spawn and insert a new turn animation in the move sequence. Has anyone tried this? In the meantime, I'll do it now and post back the results...
Thanks!
Scott