Hi all,
For a new game I need to rotate some image constantly, but using the stander rotate method from GreenfootImage gives a weird result after using it over and over every act method. So I used this code:
but, that seems to take up quite a bit of memory (I get the OutOfMemoryError earlier than before I used it).
Can someone help me and/or give me some advice what to do? Thanks in advance!
// beamOriginal is a BufferedImage // beam is the image where the rotated beamOriginal is displayed // beamGraphics is recieved by calling createGraphics() on the BufferedImage of beam. beam.clear(); double rot = Math.toRadians(getRotation()); AffineTransform at = new AffineTransform(); at.translate(beamOriginal.getWidth()/2, beamOriginal.getHeight()/2); at.rotate(rot); at.translate(-beamOriginal.getWidth()/2, -beamOriginal.getHeight()/2); beam.clear(); beamGraphics.drawImage(beamOriginal, at, null);