AffineTransform at;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
at = new AffineTransform();
at.setToTranslation(x, y);
at.setToRotation(theta);
g2.setTransform(at);
g2.drawPolygon(points);
我的代码在 x 和 y 处绘制了一个三角形……当我按下 a 和 d 时,三角形旋转……但是当我按下 w 和 s 时,三角形不会改变它的 x 和 y。
变量是正确的..这是翻译例程..我不确定我错在哪里..
如果我这样做:
AffineTransform at;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
at = new AffineTransform();
at.setToTranslation(x, y);
g2.setTransform(at);
g2.drawPolygon(points);
at.setToRotation(theta);
g2.setTransform(at);
g2.drawPolygon(points);
一个旋转一个移动.. 那么为什么我不能在绘图之前应用这两种翻译呢?