I’m making a game where some objects rotate to face what they’re shooting at. There’s a delay in between shooting and I want the object to keep facing where it is until it shoots again. I know how to load images and I know how to rotate them using AffineTransform. But with this I need to calculate the rotate every time the object gets drawn.
So my question is how can I rotate an image and save the result into a new image that would get displayed?
Create a new
BufferedImage. Get hold of aGraphicsobject (throughBufferedImage.getGraphics(). Paint the rotated image onto this buffered image, and save the image in an array or a map based on its rotation (so that it easy to look it up when you need it).