我有ImageIcon face,我不知道如何使用rotate命令来旋转玩家的脸。我知道旋转是针对点0, 0的。但是如何使用for rotate only item?
我的代码是:
int size = 40;
int angle = getAngle(); // in degree...
g2.rotate(Math.toRadians((double)angle); //????????
g2.drawImage(face.getImage(), size * col, size * row, null);有人能给我一些建议吗?
谢谢。
发布于 2015-07-11 23:27:41
在绘制图标时,可以使用Rotated Icon类更改图标的旋转度数。RotatedIcon类可用于旋转使用图标的任何组件上的图标。
您还可以使用如下代码在面板上自定义绘制RotatedIcon:
1)您可以创建类似于以下内容的图标:
RotatedIcon face = new RotatedIcon(new ImageIcon(...), 0);2)然后在你的绘图代码中使用:
face.paintIcon(this, g2, x, y); // determine you x/y location3)当你想旋转图标时,你可以使用:
face.setDegrees(...);
panel.repaint(); // then panel where you do the custom paintinghttps://stackoverflow.com/questions/31357434
复制相似问题