【发布时间】:2014-09-26 21:24:32
【问题描述】:
我用宇宙飞船制作了一个游戏,但我在移动它时遇到了问题。 这是脚本:
public class spaceship {
private final local_client local_client;
private final int startX;
private final int startY;
private final int startR;
private double x,y,r;
public static double rotation;
public static double velo;
公共静态仿射变换在;
public spaceship(local_client local_client,int startX,int startY,int startR) {
this.local_client = local_client;
this.startX = startX;
this.startY = startY;
this.startR = startR;
x=200;
y=200;
r=90;
}
public void drawImage(Graphics2D g2d) {
g2d.drawImage(local_client.spaceship_img,200,200, local_client.game);
at = g2d.getTransform();
at.translate(x , y);
at.rotate(Math.toRadians(r));
at.translate(-(local_client.spaceship_img.getWidth()/2),-(local_client.spaceship_img.getHeight()/2));
System.out.println(at.getTranslateX() + " - " + at.getTranslateY());
g2d.setTransform(at);
g2d.drawImage(local_client.spaceship_img,0,0, local_client.game);
}
所以使用这个脚本我可以旋转图像(见屏幕): http://gyazo.com/c982b17afbba8cdc65e7786bd1cbea47
我的问题是,如果我在法线轴(屏幕)上增加 X 或 Y 移动: http://gyazo.com/1fb2efb5aff9e95c56e7dddb6a30df4a 而不是对角线
【问题讨论】:
标签: java image-rotation affinetransform