I am currently working on a project where the character's arm is rotated around based on the mouse's location, using Math.atan2(). My problem is, I want the player to be holding weapons in their hand, and it gets a little weird. I'm using the sprite class for rotated images, so I have to position and then rotate the sprite in question. Currently, this is accomplished by this:
1 2 3 4 5 6 7 8
| primaryWeaponl.setRotation(aimAngle + 90); primaryWeaponl.setPosition( playerScreenX + armXDis + (float) Math.sin(Math.toRadians(aimAngle)) * (characterArm.getHeight()), playerScreenY + armYDis - (float) Math.cos(Math.toRadians(aimAngle)) * characterArm.getHeight()); |
my issue is that when I position the image, it looks just fine:


but when I add in the rotation (the first line):


I'm not sure what is causing this, but any help would be great ( sorry for the image shapes, I simply cropped them by hand

) could it be a problem with the sprite class? I've tried setting the origin for rotation, but it doesn't seem to help.