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:
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:
http://imageshack.us/a/img541/134/error1f.png
http://imageshack.us/a/img515/186/error2es.png
but when I add in the rotation (the first line):
http://imageshack.us/a/img515/8813/error4w.png
http://imageshack.us/a/img577/6536/error3mo.png
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.