An Introduction To The Box2D Physics Engine
This is the first of a range of tutorials covering use of the open source Box2D physics engine. This engine the physics engine of choice of AS3 and has more than likely been used to create some of you’re favorite games like ‘Fantastic Contraption’ and ‘Super Stacker’
I know what you’re thinking,
How am I going to learn how to code all these gravity and physics things?
The great part is, all the actual physics of the game have already been coded in the Box2D classes already. All we have to do is create the object, know as bodies in the Box2D world, and set there attributes!
In this tutorial i will cover the basics of Box2D and how it works.
The Difference
If you’re already an competent AS3 Coder, which you should be if you’re learning box2D, there are a few fundamental differences to the way things work.
In normal AS3 coding you have you’re sprites and MovieClips, they:
- Are Smart
- Calculate where to move by themselves
- Have an Event.Enter_Frame attached to them
However sprites in Box2D are completey different, they:
- Aren’t so smart
- Go where box2D tells them to go
That’s the main difference when coding Box2D, its mainly because the engine is ported directly from the world of C++
In the next tutorial, i will cover how to set up Box2D so it knows where abouts on our flash movies that physics should be applied. Also know as the B2World.





