要按旋转方向移动对象,需要 cos
和 sin
。
Math.cos ()
> 和 Math.sin ()
仅接受弧度,所以您需要将旋转转换成像您在示例中 Math.tan2(2)
那样的弧度。
样本 :
// Note: Utilising the property angle from your code.
_bullet.x += Math.cos(angle);
_bullet.y += Math.sin(angle);
然后明显地将这些值乘以一个数值 代表你希望子弹弹出的速度,例如:
var velocity:Number = 10.5;
_bullet.x += Math.cos(angle) * velocity;
_bullet.y += Math.sin(angle) * velocity;