Hey all,
I am working on a new game and I have decided to try my hand at rotation. After looking at a few tutorials and learning, I came up with this:
AnimatedSprite.java - handles the actual animation,rotation and movement of sprite
http://pastebin.java-gaming.org/827c3257f21Entity.java - just a class that handles the default attributes that all sprites will share
http://pastebin.java-gaming.org/27c353f7123And finally MainFrame.java which just tests our code
http://pastebin.java-gaming.org/7c35f417320The problem lies in my transform() method of AnimatedSprite.java
1 2 3 4 5 6 7 8 9 10
| public void transform() { at.setToIdentity(); at.translate(this.getX() + getImageWidth() / 2, this.getY() + getImageHeight() / 2); at.rotate(Math.toRadians(getFaceAngle())); at.translate(-getImageWidth() / 2, -getImageHeight() / 2); } |
When I rotate the image, it rotates but it doesn't seem to rotate around the center of the image as can be seen in the screenshot below:

Any help is appreciated but I will keep working on this. Thanks!