在使用图像时旋转图像

时间:2014-10-22 17:05:03

标签: java image rotation awt

我正在创造一款汽车游戏,我想在我使用汽车时旋转我的车(图像),但我不知道如何。我尝试了一些不起作用的东西。这就是我所拥有的:

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 个答案:

没有答案