Here is one method I use:
Write a draw(Graphics2D) method for the Sprite class.
In the painting method, you can store the current AffineTransfrom of the Graphics2D with
1 2 3 4 5
| AffineTransform emptyXform = g2d.getTransform(); for( all the sprites ){ g2d.setTransform(emptyXform); sprite.draw(g2d) } |
In the draw method of the sprite you can do any transformation necessary on the Graphics2D without wrecking anything. emptyXform simply resets the transform to one which doesn't do anything (it's probably just the identity transformation). Simply use
1
| g2d.rotate(angle, centerX, centerY); |
inside the draw() methods of the sprites.