Wednesday, January 09, 2008

Actionscript 2D Physics Engines : APE

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.

APE Bridge screenshot

Of the available Actionscript 2D Physics Engines APE is without a doubt the easiest to learn. This is partly due to good documentation, the availability of some clear tutorials and comprehensive demos. Even if these resources didn't exist APE would still be the easiest to learn. The APE Engine aims to do as much of the heavy lifting for you as is possible. The process for creating a working simulation might be :

  • Initialise APE Engine with APEEngine.init()
  • Add gravity with APEngine.addForce()
  • Create a group
  • Create a particle (e.g RectangleParticle)
  • Add particle to group
  • Add group to APEngine with APEngine.addGroup()
  • Add an enterFrame listener (and function)
  • Call APEngine.step() and APEngine.paint() in the enterFrame function

The downside to simplicity is reduced flexibility. I had no problems building either the Hello World or the Rope Bridge simulations. Where I ran into problems was creating the Stunt Bike. The issue is that there is only one type of contraint (the SpringConstraint) and this doesn't have many properties. This limitation is particularly apparent when you look at the Box2DFlashAS3 which has 6 distinct types of constraint (called joints).

Another limitation of APE is that there is no support for complex shapes. The engine creates three types of object ; a RectangleParticle, a CircleParticle, and a WheelParticle (a CircleParticle that turns when in contact with a surface). This is offset in a small way by letting you set a MovieClip as the Particles DisplayObject, but this is possible with all the engines.

In summary, APE is easy to learn and use but a limited feature set will make it unsuitable for more complex projects. Having said that APE is still in it's alpha version and this may not be the complete set of features. There isn't a project roadmap available so it is unclear what a full feature set may contain.


Mike said...

Have you had any luck reqriting the class files and getting ape to work with flash cs4/flash player 10?

geekglue said...

Thanks for the comment Mike. This review was part of a series of reviews looking at all the available Flash physics engines. In the end I was happiest with Box2DAS3. I went on to develop two games using this engine:

Wheel Of Death
Perpetual Motion

Anonymous said...

Hmm.. I've thought about this very much..... it sure raises a few questions..