Physics engine

The Citrus Engine supports Box2D and Nape physics engine. Those engines are top gun features to make complex game behavior: collision detection, real physics simulation, raycasting, … You should have a look on their documentation for understanding the basis of a physics engine.

Box2D or Nape?

This has been discussed many time. Both have advantages and inconvenients. From features point of view, they have the same. However those are some details to help you to pick the one you need:


  • Advantages:
    • It is the most popular 2D physics engine, ported in many programming languages. It means that you can find many examples on the internet (implemented in Java, Objective-C, C++, …).
    • It has a huge community, have a look on theforum.
  • Inconvenients:
    • It's hard to start with it if you have never work with a physics engine due to its complex API.
    • Most body changes need to be done outside of a world simulation which sometimes require delaying some of your code to a citrus update call.


  • Advantages:
    • Performances!! Nape is really faster than Box2D. If you want to make a mobile game, we highly recommand to use it over Box2D.
    • It has a very simple and powerful API, perfect to learn a physics engine.
    • Though its not recommended for consistency, shapes can be swapped for other shapes, bodies can be “disabled” and other things can be done in the middle of a simulation without the engine behaving too badly so you have less things to worry about compared to box2D's system
  • Inconvenients:
    • The engine can only be used with AS3 and Haxe, so it doesn't have a big community.

Getting started with a physics engine

Thanks to the Platformer Kit, you are able to see an implementation of physics objects having different behaviors. It is easiest to learn physics engine with living examples.

  citrus/physics.txt · Last modified: 2013/11/15 03:35 by gsynuh
Powered by DokuWiki