We are starting with an easy task, the simplest of all physics simulations: a ball falling on the floor. Anyway, although it's just another falling ball, being your first simulation this will be quite an achievement.
Let's see what we have in our simulation:
A world with a gravity
A ball that should react to world forces (such as gravity)
A floor that shouldn't react to world forces
Some kind of materials, as we expect the ball to bounce on the floor
You are already able to configure a world with gravity, so we are going to start with the creation of the ball.
It doesn't matter if we are creating a sphere or a polygon, the first step to create a body is:
var bodyDef:b2BodyDef=new b2BodyDef();
b2BodyDef
is the body definition, which will hold all data needed to create our rigid body.Now it's time to place the body somewhere in the world. As we are working on a 640 x 480 size, we'll place the ball in the top-center position of the stage, let's say...