AS3:以旋转角度移动物体

Geo*_*ith 3 flash actionscript actionscript-3

所以我现在有一半工作,我说这一半是有效的,因为它似乎以某种方式将角度绕到最接近的45度左右,这里是代码:

public function drive(e:Event)
{
    speedX =Math.sin(carObj.rotation*(Math.PI/180))*2;
    speedY = Math.cos(carObj.rotation*(Math.PI/180))*2*-1;
    carObj.x +=  speedX * speed;
    carObj.y +=  speedY * speed;
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道一个更好的方法,它将得到精确的(可见至少让眼睛无法分辨)旋转角度,并以给定的速度在该方向上平移物体.

Geo*_*ith 8

没关系解决了:

var carAngle:Number = carObj.rotation * Math.PI / 180;
carObj.x = carObj.x + speed * Math.cos(carAngle);
carObj.y = carObj.y + speed * Math.sin(carAngle);
Run Code Online (Sandbox Code Playgroud)