Im trying to rotate a body around its center in box2d. The rotation of the sprite works, but what the body does is rotate around its top left point.
Code for rotating the sprite:
public void drawBitMap(Bitmap bit, float x, float y, float width, float height, float rotation){
Sprite sprt = null;
if (!sprts.containsKey(bit)) {
sprt = new Sprite(bit.texture);
sprts.put(bit, sprt);
}else{
sprt = sprts.get(bit);
}
sprt.setOrigin(width/2,height/2);
sprt.setRotation(rotation);
sprt.setPosition(x,y);
sprt.setSize(width,height);
sprt.draw(this);
}
Code for rotating body:
body.setTransform(x, y, rotation * MathUtils.degreesToRadians);
Images of what is happening: