Physics Engine Simulation Flash ActionScript Tutorial
Physics Engine allows simulation of the physics world (e.g. falling objects, object sliding down a slope, bouncing objects, etc.) easily without writting extensive Flash ActionScript codes. There are some Flash ActionScript 3 Physics Engines on the Internet. This is better to choose the most suitable Physics Engine to suit your needs. In our flash actionscript tutorials, we use Box2D Physics Engine to do some physics simulation with a lot of interesting examples.
Steps in Simulating Box2D Physics World
You can use Flash ActionScript 3 code to create very interesting Physics Systems, for example, sliding slope, falling objects, bouncing object, prismatic engines joints, etc. It requires more knowledge of ActionScript. Therefore this is better to learn other flash actionscript tutorials before starting this topic.
Step 1: Create a Virtual World
Every Box2D program begins with the creation of a world object with definition of gravity and sleep. This is the physics hub that manages memory, objects, and simulation.
Step 2: Create Ground or Floor
Now we have our virtual world. There is nothing in our world. The first thing we need to add to our world is the ground (earth or floor). This step is optional. You can simulate a physics world without a Ground.
Step 3: Create Dynamic Bodies
To simulate the physics world, we have to add at least an dynamics object (e.g. falling box) to our world. The techniques in creating the Ground body and Dynamic Bodies are the same EXCEPT that we must establish the dynamic body's MASS properties. The basic mass properties of dynamic bodies are density, restitution and friction.
Step 4: Simulate Our Physics World
Now we have all necessary objects, the physics world is ready to simulate. You need to define the frame rate and the iterations to do the simulation.
All our tutorials of Flash ActionScript 3 Physics Engine show detailed codes with steps by steps. Okay, let's get started.......
This Flash ActionScript tutorial shows how to simulate a Physics world with Box2D Physics Engine.