Java graphics2D turning

微信扫一扫,分享到朋友圈

Java graphics2D turning

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.

微信扫一扫,分享到朋友圈

Java graphics2D turning

TypeScript 3.8 EcmaScript Private Fields by Example

上一篇

如何改造vue-cli,将mockjs嵌入到webpack

下一篇

你也可能喜欢

Java graphics2D turning

长按储存图像,分享给朋友