Hard things first; we are going to start with one of the most difficult joints. Sad but necessary, as it will allow us to create and test other joints easily.
A mouse joint allows a player to move bodies with the mouse, and we will create it with the following features:
Pick a body by clicking on it
Move a body following the mouse as long as the button is pressed
Release a body once the button is released
Some quiet before the storm; the beginning of this process does not differ to other scripts you have already mastered through the book.
So, we are importing the required classes:
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.*;
Then we need the class-level variables for the world itself, and the conversion from pixels to meters:
private var world:b2World; private var worldScale:Number=30;
And even the
Main...