0

当我从大炮中射出球时,球并没有准确地射在鼠标点击的鼠标位置上。在某些角度看起来不错,但其他角度则偏离了几度。这是正确的公式吗?

谢谢

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);
}
4

1 回答 1

1

That looks right at first glance.

How are you determining that it is "off"?. Have you accounted for the registration point on "tank"? Is it off consistently in the same vectors or is it random? I don't suppose that you have the swf posted on the web somewhere?

于 2011-03-03T21:26:11.450 回答