Which Physics Engine for Flash and AIR apps?

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 –

  1. Box2D – The most updated and authentic source of AS3 port of Box2D
  2. Box2D FlasCC-ed – FlasCC-ed version of native Box2D library
  3. 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).

Flash Builder projects for the above tests are available here – Box2D, Box2D FlasCC, Nape.

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.


One comment

  1. hi, how did you manage to get 42 frames with nape on an iphone4? how did you configure your project? i’m using fdt free for testing nape, but can’t get even near 15 fps!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s