The image below exemplifies what I am trying to do.The polygon body should rotate keeping its initial position and the red point, which could also be another body, stays in the center.
Here is what I have tried, however it moves something like around the red point:
Vector2 position = body2.getWorldCenter();
body2.setTransform(position, body2.getAngle() + 0.01f);
Any thoughts?
UPDATE 1
Here is how a create the Polygon body:
private Body createPolygonBody(Vector2 pos) {
// 0. Create a loader for the file saved from the editor.
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("shot/wall"));
// 1. Create a BodyDef, as usual.
BodyDef bd = new BodyDef();
bd.position.set(pos);
bd.type = BodyType.StaticBody;
// 2. Create a FixtureDef, as usual.
FixtureDef fd = new FixtureDef();
fd.density = 1;
fd.friction = 0.5f;
fd.restitution = 0.3f;
fd.filter.categoryBits = CATEGORY_SCENERY;
fd.filter.maskBits = MASK_SCENERY;
// 3. Create a Body, as usual.
Body body = world.createBody(bd);
// 4. Create the body fixture automatically by using the loader.
loader.attachFixture(body, "one_door",fd, 3f);
return body;
}