Game Development Reference
In-Depth Information
7.
And the update callback:
private function updateWorld(e:Event):void {
world.Step(1/30,10,10);
world.ClearForces();
world.DrawDebugData();
}
8. Ok, ready to test the movie finally:
9.
Click here and there and nothing will happen until you click on the small
dynamic box, which will prompt the following text in the output window:
will create joint here
And actually, this is where we are creating the mouse joint.
10. Joints are defined in a separate class we have to include:
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.Joints.*;
11. And we also need to declare a new class-level variable which will store our
mouse joint:
private var world:b2World;
private var worldScale:Number=30;
private var mouseJoint:b2MouseJoint;
This is quite intuitive: the b2MouseJoint class is what we need to handle
mouse joints, so I declared a variable of such type, called mouseJoint .
 
Search WWH ::




Custom Search