0
如何實現在cocs2dx一Box2D的身體拋運動....彈丸運動框中2D物體
newX = b4->GetPosition().x + cos(60.0);
newY = b4->GetPosition().y + sin(60.0);
這是一個正確的方式?
如何實現在cocs2dx一Box2D的身體拋運動....彈丸運動框中2D物體
newX = b4->GetPosition().x + cos(60.0);
newY = b4->GetPosition().y + sin(60.0);
這是一個正確的方式?
你可以像對象,角度,重力= 9.81的初始速度那樣做,時間應該從零開始。
while(count < 10)
{
// this is formula for trajectory
// http://en.wikipedia.org/wiki/Projectile_motion
x = initialVelocity * time * Math.Cos(angle);
y = initialVelocity * time * Math.Sin(angle) - 0.5f * gravity * time * time;
count++;
time += 0.1f;
}