2010-11-27 91 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 ; 
} 

上面是樣品例如計算速度爲我的推杆