Thursday, January 10, 2008

Actionscript 2D Physics Engines : Box2DFlashAS3

This post is part of a series reviewing the available Actionscript 2D Physics Engines. Each engine was tested through the development of three simple simulations; Hello World, Rope Bridge and Stunt Bike. You can find out more about the testing methodology and access the other reviews from the introduction post.


Box2DFlashAS3 is the most difficult Actionscript Physics Engine to learn. Like Motor 2 it is a port of Erin Catto's C++ physics library Box2D but unlike Motor 2 little effort has been made to assimilate the engine to Actionscripts methodologies. Consequently Box2D's approach may seem a bit foreign to some Actionscript developers. It's only documentation is that provided by Erin Catto for the C++ version and there are very few helper functions to ease the developers burden. To be honest my first instinct was to stay as far away from Box2DFlashAS3 as was possible. Fortunately Box2DFlashAS3 offers an excellent collection of demos covering a wide range of use cases. It also offers 6 distinct joint types and a lot of flexibility in how you create DisplayObject's for your particles. Once I got over the initial shock I found Box2DFlashAS3 was a workable tool. I had no trouble building the Hello World and Rope Bridge simulations and while I'm no where near happy with the Stunt Bike. I'm fairly confident that most of the problems are my own rather than the engines.

In summary, Box2DFlashAS3 offers a substantial learning curve but there are a lot of payoffs. This is partly because Box2DFlashAS3 is the most mature of the available engines (current release version : 1.4.3). It certainly helps that it is a comprehensive port of an existing engine. I still think I'd prefer to be able to use one of the other engines. But because I'm keen to do 2D Physics in Actionscript today then I think Box2DFlashAS3 is my only real option.


antoniobrandao said...

wha is it for you compared to motor2 ? right now I'm using motor2 because of all the force classes it contains. which one is the most complete ?

geekglue said...

Thanks for the comment Antonio. Both Box2DFlash and Motor2 have released updates since the time of this post but I haven't had time to look at either of them. Consequently I'm in no position to make an informed recommendation about either.