I am trying to transform a moving animated sprite to be a reverse of itself. The only way I know of do this is:
AffineTransform transform = new AffineTransform();
transform.scale(-1, 1);
transform.translate(-sprite.getWidth(), 0);
g.drawImage(imageFromSprite, transform, null);
Because there seem to be no methods to enter coordinates with the transform it means I am unable to carry on running my code which moves the animated sprite around the screen.
Is there a way of transforming an image and drawing it at specified coordinates?
Any help greatly appreciated.
Write yourself a method that performs the transformation and accepts the coordinates as parameters.
ex:
I’m assuming that the transform.translate() method is actually doing the image reversal.