How can I get the velocity of my sprite?
I want to knew the velocity of my开发者_JAVA技巧 sprite. How can I do that? Is there any formula(is that the word?)...
If you only knew the answer with cocos2d. No problem I can cocos2d!
PS: My English isn't so well.
Velocity is defined as distance divided by time. So you would divide the pixels your sprite traveled within a given time period by the time elapsed.
CGPoint diff = ccpSub(new_location, oldTouchLocation);
CGPoint currentpos = [para6 position];
CGPoint destination = ccpAdd(currentpos, diff);
if (destination.x < 80 && destination.x > 20)
{
Velocity = (20 + (80-destination.x))*1.8 ;
}
above is the sample example calculating velocity for my plunger
精彩评论