我想知道我的精灵的速度。我怎样才能做到这一点?有没有公式(这个词是什么?)......
如果你只知道cocos2d的答案。没问题,我可以cocos2d!
PS:我的英语不太好。
答案 0 :(得分:1)
速度定义为距离除以时间。因此,您可以将精灵在给定时间段内经过的像素除以经过的时间。
答案 1 :(得分:1)
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 ;
}
以上是计算柱塞速度的样本示例