0

キャラクターをマウスの方向に回転させて「発射」したい単純なシューティングゲームをコーディングしています。実際の画像を回転させることを除いて、このためのすべてのコードを実行しました。これまでのコードの一部を次に示します (これはすべて、ペイント コンポーネント メソッドの下にあります)。

   xCent = x + 50;
    yCent = y + 50; // x and y center of image ( x and y change depending on Keyboard Input)       
    a.setToRotation(theta, xCent,yCent); // a = new AffineTransform()    Here is my calculation of theta (under the MouseMotionListener):  theta = Math.atan2(e.getY() - yCent,e.getX() - xCent);
    a.setToTranslation(x,y);
    a.setToRotation(theta, xCent,yCent);
    g2.drawImage(charac,a, null);

Graphics2D オブジェクトが画像を描画するために、画像の x 座標と y 座標を「設定」するにはどうすればよいですか??

4

1 に答える 1