I need that my body rotate around specific point like shown in picture. I already done that by this line of code (Please let me know if there is a better way)
PolygonShape shape = new PolygonShape();
shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(2,2), 0); // vector2 is
now I want to position sprite accordingly to my rotating body. Here what I did
sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
sprite.setPosition(body.getPosition().x * 32 - sprite.getWidth() / 2, body.getPosition().y * 32 - sprite.getHeight() / 2);
and here how I draw everything
public void draw(SpriteBatch sb){
System.out.println(body.getWorldCenter());
sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
sprite.draw(sb);
}
Strange things happen when I run my code. I seee that body rotating correctly, but sprite rotates around its origin (middle of a sprite) because of this line sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
however I need that sprite position would be always the same as my body position. How can I cheve this?