A distance joint is probably the easiest joint to understand and handle. It just sets the distance between two points of two objects, and it will remain constant, no matter what happens.
So we are about to create a new box and link it with the distance joint to the one already in the world. Time to change a bit in our Main
function:
public function Main() { world=new b2World(new b2Vec2(0,9.81),true); debugDraw(); var bodyDef:b2BodyDef=new b2BodyDef(); bodyDef.position.Set(320/worldScale,470/worldScale); var polygonShape:b2PolygonShape=new b2PolygonShape(); polygonShape.SetAsBox(320/worldScale,10/worldScale); var fixtureDef:b2FixtureDef=new b2FixtureDef(); fixtureDef.shape=polygonShape; var groundBody:b2Body=world.CreateBody(bodyDef); groundBody.CreateFixture(fixtureDef); bodyDef.position.Set(320/worldScale,430/worldScale); bodyDef.type=b2Body.b2_dynamicBody; polygonShape.SetAsBox(30/worldScale,30/worldScale); ...