我正在使用 AffineTransform 变换炮塔的枪管,我希望子弹从枪管尖端直接射出。是否有形状方法来获取这些坐标,还是我必须手动计算?
转换代码
AffineTransform rotate = AffineTransform.getRotateInstance(rotation, getX() + getWidth()/2, getY() + getHeight()/2);
barrel = rotate.createTransformedShape(new Rectangle(getX() + getWidth()/2, getY() - getHeight()/2, 2, getHeight()/2 + 1));
子弹代码
int dx = getX() - o.getX();
int dy = o.getY() - getY();
bullets.add(new Bullet((int)barrel.getBounds2D().getX(), (int)barrel.getBounds2D().getY(), SPEED, new NVector(dx, dy)));