2010-11-27 56 views

回答

1

速度被定义为距离除以时间。所以你可以将你的精灵在给定时间段内行进的像素除以时间。

+0

你可以让一个例子吗? – cocos2dbeginner 2010-11-27 22:54:28

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 ; 
} 

上面是样品例如计算速度为我的推杆