How do I control an animation with a drag command?

Posted by Zishan on Game Development See other posts from Game Development or by Zishan
Published on 2012-04-10T14:47:23Z Indexed on 2012/04/10 23:45 UTC
Read the original article Hit count: 205

Filed under:
|

I want to play an animation when someone drags a sprite from it's default position to another selected position. If they drag half of the selected position then animation will be play half. For example, I have 15 frames of a animation for a projectile arm. The projectile arm can be rotated a maximum of 30°, if someone rotates the arm 2° then the animation sprite should show the 2nd frame, if rotated 12° then the animation sprite should show the 6th frame.... and so on. Also when they release the arm, the arm will be reverse back to it's default position and animation frames also will be reverse back to the default first frame.

I am new on cocos2D. I know how to make an animation and how to drag a sprite but I have no idea how to combine them. Can anyone give me an idea or any tutorial on how to do this?

© Game Development or respective owner

Related posts about animation

Related posts about cocos2d-iphone