以一定角度射球?
当我从大炮中射出球时,球并没有准确地射向鼠标点击的鼠标位置。在某些角度看起来不错,但在其他角度则有好几度的偏差。这是正确的公式吗?
谢谢
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);
}
When I shoot the ball out of my cannon, the ball does not shoot exactly at the mouse position of the mouse click. At certain angles it seems fine, but others its off by several degrees. Is this the correct formualas?
thanks
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
乍一看是这样的。
你如何确定它是“关闭”的?你计算过“坦克”上的注册点了吗?它是在相同的向量中一致关闭还是随机的?我不认为您已将 swf 发布到网络上的某个地方?
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?