开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜