【发布时间】:2010-05-20 12:29:47
【问题描述】:
我已经环顾四周,但我根本找不到一个好的解决方案......
Point mouse = MouseInfo.getPointerInfo().getLocation();
int dx = (BULLET_SPEED*Math.abs(x - mouse.getX()))/
(Math.abs(y - mouse.getY()) + Math.abs(x - mouse.getX()))*
(x - mouse.getX())/Math.abs(x - mouse.getX());
在这个星座中,我得到:可能的精度损失,当我将 (x - mouse.getX()) 更改为 (x - mouse.getX()).doubleValue() 时,它说 double 不能被取消引用,当我在某处添加 intValue() 时它说 int 不能被取消引用。我的错误是什么?
[x, y 是整数 | BULLET_SPEED 是static final int]
谢谢!
【问题讨论】: