有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在使用图像时旋转图像

我正在创建一个汽车游戏,我想在使用汽车时旋转我的汽车(图像),但我不知道如何旋转。我试过一些不起作用的东西。以下是我所拥有的:

g2d.drawImage(DEFAULT_CAR_SKIN, DEFAULT_BOX.x, DEFAULT_BOX.y, null);

DEFAULT_BOX.setLocation(DEFAULT_BOX.x + 1, DEFAULT_BOX.y);

if (Game.rotateFront == true) {
  AffineTransform identity = new AffineTransform();

  AffineTransform trans = new AffineTransform();
  trans.setTransform(identity);
  trans.rotate(Math.toRadians(Game.Angle));
  g2d.drawImage(DEFAULT_CAR_SKIN, trans, this);
}

但这段代码绘制了一个新的图像,但具有我想要的特征


共 (0) 个答案