对于我编程的游戏,我有一个围绕它的鼻子旋转的船舶对象(不是船的中心)。边界框应随之旋转以保持一致的命中检测,但我似乎无法使其工作。这就是我所拥有的:
if(ship.isAlive())
{
g2d.setTransform(identity);
g2d.translate(ship.getX(), ship.getY());
g2d.rotate(Math.toRadians(ship.getFaceAngle()));
g2d.setColor(Color.WHITE);
g2d.fill(ship.getShape());
g2d.setColor(Color.RED);
g2d.draw(ship.getShape());
//draw bounding rectangle around ship
if (showBounds)
{
g2d.setTransform(identity);
g2d.setColor(Color.BLUE);
g2d.draw(ship.getBounds());
}
}