How can i move an Body regarding to Dynamic body position?

Hi guys,

i'm moving a Dynamic body (call it earth) with my arrow keys, and i need to move another body - lets call this one a moon (one without collision - it's representing a gfx sprite for the final version in my testbed) around the earth(calculating the position is not the problem)

so how can i update the position for the moon, when earth changes its position?

thanks in advance!
finally resolved!

Code: Select all


      Body body = earth;
      World world = body.getWorld();

      CircleShapeBuilder csb = new CircleShapeBuilder(world);
      csb.type(BodyType.DYNAMIC);
      csb.radius(1f);
      csb.position((float) (body.getPosition().x),
            (float) (body.getPosition().y + offset));
      csb.angularDamping(0f);
      csb.userData(this);
      moon = csb.build();

      RevoluteJointDef jointDef = new RevoluteJointDef();
      jointDef.initialize(body, moon, body.getWorldCenter());
      world.createJoint(jointDef);

Original thread: https://box2d.org/forum/viewtopic.php?t=8795