I’m making a game in Java, but I’m having a problem when rotating an image.
When I’m rotating an image using graphics2D, the image’s X and Y is changing on the screen. Still when I’m getting the image’s X and Y, the value is the same as it was before being rotated. On the screen however, it’s displayed on another position.
Anyone who knows a method or formula that can get the image back to the original position?
You need to set the point of rotation to the middle of your image (or whatever object you’re rotating).
For example, if the image you want to rotate is 20x20px then the point of rotation should be at (X_POS + 10, Y_POS + 10);
X_POS and Y_POS are the coordinates of the upper left vertex of your image on the screen.