2
\$\begingroup\$

my cocos2d game currently has a ccsprite attached to a box2d body. during the game i apply different CCAnimations on my sprite, i would like to perform certain manipulations to the box2d body according to the frame currently displayed by the sprite (change rotation of the body, etc.) my current idea on implementing this is to subclass ccsprite and change the setDisplayFrame implementation but i thought somebody here probably did the same and already has a solution, so any suggestions on how to implement this?

thanks!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I think you couple the wrong components when you do this. What you should do is implement a custom CCAnimate where you not only update the animation frame of your sprite but also the "animation frame" of your physics box. Otherwise you are coupling drawing and physics components directly.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .