当我从大炮中射出球时,球并没有准确地射在鼠标点击的鼠标位置上。在某些角度看起来不错,但其他角度则偏离了几度。这是正确的公式吗?
谢谢
public function setPos() {
destX = gameManager.stage.mouseX;
destY = gameManager.stage.mouseY;
var dx:Number = destX -gameManager.tank.x;
var dy:Number = destY - gameManager.tank.y;
radians = Math.atan2(dy, dx);
}
public function Shoot() {
this.x += speed * Math.cos(radians);
this.y += speed *Math.sin(radians);
}