I did a small comparison of the most common ways in which a Flash or an AIR developer makes use of a physics engine in a game.
The test involves creating 50 dynamic bodies with full bounce and dropping them in a walled enclosure and normal gravity. And this test was tried with the following 3 engines –
- Box2D – The most updated and authentic source of AS3 port of Box2D
- Box2D FlasCC-ed – FlasCC-ed version of native Box2D library
- Nape – 2D Physics engine for AS3/Haxe
And here are the results –
|Engine||MacbookPro (with DD*)||MacbookPro (without DD)||iPhone4 (with DD)||iPhone4 (without DD)|
|Box2D AS3||45 fps||60 fps||20 fps||42 fps|
|Box2D FlasCC-ed AS3||60 fps||60 fps||14 fps||30 fps|
|Nape||60 fps||60 fps||42 fps||58 fps|
* DD stands for ‘DebugDraw’, which refers to drawing the physics bodies on every enter frame.
Based on the small tests that I performed, Nape seems to be the winner. Trent’s blog mentions the primary reason behind this as Nape being developed keeping Flash in mind (which was not the case with Box2D).
I found two projects for native extensions as well – by TryHarder and Digital Architect. Unfortunately however, I could not build the ane from any of the two sites and the sources don’t seem to be complete.