Hey guy’s im making a 2D java game and i want to learn how to rotate a simple 2D sprite.
Currently my Player class has a rotation integer which decreases/increases on button press. How would i go about rotating my Player image?
This is how I am loading my sprite:
ImageIcon i = new ImageIcon("player.png");
sprite = i.getImage();
This is currently how i draw it:
public void paint(Graphics g) {
g.drawImage(player.getImage(), player.getX(), player.getY(),null);
print("Painting");
}
Any help is appreciated.
What you are looking for is AffineTransform,
below link will help you to get started
http://www.javalobby.org/java/forums/t19387.html
http://download.oracle.com/javase/tutorial/2d/advanced/transforming.html
Good luck!