I'm working on a game that uses Box2D for defining a physics world. I can easily simulate the bodies in my world using the Box2D APIs and update the positions of sprites (in a layer, for example) that visually represent characters as they're running around the world.
What I'd like to do, is animate the characters as they're moving in the world. Ideally I would be able to create a CCAnimate sequence and have that running when the bodies are moving, and not moving when the bodies stop. Something like:
CCAnimation* runAnimation = [CCAnimation animationWithName:@"walking" delay:0.1f frames:walkingAnimationFrames];
_runAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation: runAnimation restoreOriginalFrame: NO]];
[_sprite runAction: _runAction];
Another option would be to setup a timer (or use "update") to update sprites manually and change the speed of the animation as a function of the velocity of the character running in the physics world.
Are there other options? Any suggestions on how to do this otherwise?
Thanks!