The AndEngine PhysicsEditor Extension

[Update] Now supports circle sprites. Also, Andreas Löw, the creator of PhysicsEditor will link to it with the next update of the editor. [/Update]

If you ever created a physics game, for example with my favorite game engine, AndEngine, and wanted to produce a polygonal body, you probably did something that sucked big time. Something like defining your vertices in code. This is

  1. Dirty
  2. Really painful
This is why we looked around and found the PhysicsEditor, a simple to use tool to create an output that describes physic definitions. While iOS integration seemed to work both from the editor into the code, it only provided an AndEngine Exporter-format, but no tool to integrate it back into the engine.
Until today.



Here is what it’s capable of:
  • Definitions of (multiple) bodies
  • Definitions of (multiple) fixtures
  • Definitions of polygon shapes
  • Definitions of circle shapes
  • Definition of density, friction and elasticity
  • Definition of dynamic and non-dynamic bodies
  • Definition of sensor and non-sensor fixtures
  • Collision filtering
  • Automatic setting of a body’s user data


How to use it

For this part I assume you already know the very basics of AndEngine development. Let’s start from the beginning.

First, download the PhysicsEditor. Open it and import your sprite of choice. I chose the star from the examples project:

Now, draw your physical representation. You might want to use the Shape tracer for that (the wand icon):Now make your settings on the right

and push ‘publish as’. Save your XML somewhere.

Next, it’s time to get the source. Clone the repository using something like git clone git:// Import the source. Now, make sure you also have the AndEngine and the AndEnginePhysicsBox2DExtension in your workspace. You may have to update this dependencies.

A good match: PhysicsEditor Extension, Box2D Extension, AndEngine and PhysicsEditor Examples

A good match: PhysicsEditor Extension, Box2D Extension, AndEngine and PhysicsEditor Examples

Now in your project, create a new PhysicsEditorLoader-object using the default constructor:
final PhysicsEditorLoader loader = new PhysicsEditorLoader();
Use it to load whatever you want:

try {
loader.load(this, mPhysicsWorld, "xml/", "star.xml", star, true, true);
} catch (IOException e) {

The parameters provided are a Context, the PhysicsWorld you want to attach your body to, the base path, the path to your specific definition, the IAreaShape (for example a Sprite) you want your definition to be connected to, whether you want your object’s position to be updated and whether you want your object’s rotation to be updated. And that’s it.

There are some other use cases covered like drawing lines for debugging or loading multiple definitions, but that’s not more than about five keystrokes of additional work. You can take a look at the examples to see what I mean (in case you are curious).
It is possible to use the PhysicsEditor as a tool for level creation. In fact, it enables you to actually ‘draw’ your levels in your graphics tool of choice. Please keep in mind though that the maximum size of an IAreaShape in AndEngine is 2048 pixels, so you may want to use multiple sprites to achieve big levels. Also, memory is low on mobile devices, depending which device your are targeting, you maybe want to think about using a different method than this.


A ball jumping on a polygonal physical representation

A ball jumping on a polygonal physical representation

Please keep in mind that this is a very early release that may still contain some bugs and needs some refactoring. Please feel free to leave any issue you discover in the project’s issue tracker.

So far, we have tested the four sample projects on the following devices:

  • Samsung Galaxy Y (2.3.6)
  • Nexus One (2.3.6)
  • Galaxy Nexus (4.0.4)


  1. Yeah, PhysicsEditor is a GREAT piece of software! I’m curretly using it in my new motocross game and I could NOT make it without this editor :)

    • Hey Pawel,
      long time no comment, great to have you back!
      Indeed, it really provides a solid foundation for almost any form of Box 2D development. It’d have been really hard to write an editor like this on one own (but even harder to edit Box 2D polygons in code all the time). Kudos to Andreas!

      Best regards

  2. Nice extension – good job! ;-)

    I just wonder what was so bad about the included one? Was it too well hidden in the examples folder? Or did it not fit your needs?

    • Thank you for your comment Andreas!
      I didn’t realize that there actually is an examples folder coming with the PhysicsEditor. Where can I find it?

      Best regards

  3. On MacOS it’s inside the .dmg file – on windows it’s installed inside the app’s folder (C:\Program Files (x86)\PhysicsEditor)
    Ok – I see that I need to find a better place – or at least add a hint where to find it….. ;-)

    • Ah, now I found it. Could have looked into the .dmg earlier. It’s interesting to see the differences. Your parser is targeting the GLES 1.1 branch, so I can say that it somehow didn’t fit my needs. Maybe you could ask Nicolas to make it an official extension, this probably would be the way to get most people’s attention.

  4. how I can add the project to eclipse?

  5. Thank you so much!

  6. Hi Johannes and thanks for your extension!
    Just a few questions :) In eclipse doesn’t seem to like “loadLevelFromAsset(pContext, pAssetPath);” – The method loadLevelFromAsset(AssetManager, String) in the type LevelLoader is not applicable for the arguments (Context, String).

    Also it doesn’t like void in “public void onLoadEntity(String pEntityName, Attributes pAttributes) { ” – The return type is incompatible with IEntityLoader.onLoadEntity(String, Attributes).

    Any ideas what’s wrong with it?
    Thanks again! :)

  7. When I try to run the examples I get the following error:

    [05.02.2012 15:46:31 – AndEnginePhysicsLoaderExtension] Installing AndEnginePhysicsLoaderExtension.apk …
    [05.02.2012 15:46:35 – AndEnginePhysicsLoaderExtension] Success!
    [05.02.2012 15:46:35 – AndEngine] Could not find AndEngine.apk!
    [05.02.2012 15:46:35 – AndEnginePhysicsBox2DExtension] Could not find AndEnginePhysicsBox2DExtension.apk!


    • Hi Dani,

      I’ve seen this as warnings in other projects before but not as errors. Did you add the AndEngine and Box2DExtension properly?

      Best regards

  8. Hey. I stumbled upon this amazing gem but I’m having difficulty using it. I’m working on a game and I originally had Rectangular bounds for one of my sprites. I used the PhysicsEditor to export the XML with the complex bounds. After getting the code in, I there was no collision. I then tried out all the examples. I had difficulty and I documented the errors here.

    Could you help me out or perhaps make another post about the Physics Editor Extension. I’m curious about altering the rigidbody properties of a complex shape (changing velocity, angular rotation etc…). I really want to integrate this tool into my project. This type of tool can simply take android gaming to a whole new level.

  9. As Roger said:

    In eclipse doesn’t seem to like “loadLevelFromAsset(pContext, pAssetPath);” – The method loadLevelFromAsset(AssetManager, String) in the type LevelLoader is not applicable for the arguments (Context, String).

    Also it doesn’t like void in “public void onLoadEntity(String pEntityName, Attributes pAttributes) { ” – The return type is incompatible with IEntityLoader.onLoadEntity(String, Attributes).

    I can’t solve this errors. Help please.


  10. Thanks for that, have you been thinking about implementing it for latest GLES2 Anchor Center AndEngine branch?

    • You’re welcome. Yes, I have. But it will take some time since my priorities are on some other project first. But since an open source project: Feel free to commit any changes you make :)

      Best regards

      • An AndEngine GLES2 AC Version would be great.
        I hope you can find some time to create one.
        I would love to do it myself but unfortunately I neither understand your source code nor the AndEngine well enough.
        And I have no idea how I’d have to change it to get it to work with AnchorCenter

  11. Hi, thanks for tutorial and to Andreas Lowe for texture packer and physics editor, I was just wondering how to use PE with Tiled/animated sprites, if anyone has an idea….

  12. Hello, what are you using for your level editor? I am using Andengine GLES2 Anchor Center. Thanks

  13. This looks great. Looking forward to trying it out.

  14. hi, I am getting problem with andengine gles2 and physics editor. when i use multiple xml in 1 level first xml works fine and remaining have issue about body creation and position, mean sometime body not created and somtime it created but with different position and image on different position.
    someone told me that i am using wrong version of physics editor.
    I am using Andengine Gles2. please guide me about which version of physics editor i should use for compatibility.?

    • Hi Zeeshan,

      since the first XML works fine, this probably isn’t a problem of the version. Are you calling reset() after the first XML?


  15. Thanks for replying. My problem solved by recreating xml and calling reset. Thanks for such a fantastic editor.

  16. Juan Díaz

    2013/07/17 at 09:34

    Hi Johannes:
    I’m using PhysicsEditor and i want to touch and drag a body created with it. My problem is that i don’t know how to refer to the body created with PhysicsEditor. I use this lines to create it:
    final PhysicsEditorLoader loader = new PhysicsEditorLoader();
    try {
    loader.load(this, mPhysicsWorld, “xml/simple_asset.xml”, mBigAsset,false, false);
    } catch (IOException e) {
    When you create a body in AndEngine you can refer to it this way:
    body.setLinearVelocity(new Vector2(10,0));
    How can i do that with a body created with PhysicsEditor?

    Thank you very much.

    • Hi Juan,

      please excuse my late reply.
      You can use getBody(final String pName) to retrieve a loaded body or getBodies() for all bodies.

      Best regards,

      • please explain full code. how to use joint like Revolute Joint its need body how to use physics editor body.

  17. I use both the PhysicsEditor and TexturePacker. Great tools. Keep up the good work. Thanks tons.

  18. Hi Jaun, when i make body dynamic in physic editor and make another dynamic body from andengine box2d code then these two bodies does not collide sometime and collide sometime with very wrong position. When i make physics editor body static then everything works fine.
    Could you tell me where i am getting wrong while creating dynamic body. Also when i create dynamic body i set body update position and rotation disable.

  19. how to use like joints

    carbody = new Sprite(CAMERA_WIDTH/2-10, CAMERA_HEIGHT/2-70, bodyTextureRegion, this.mEngine.getVertexBufferObjectManager());

    rjd2 = new RevoluteJointDef();
    rjd2.initialize(wbody2, Body, wbody2.getWorldCenter());

  20. Hey, i use the physicseditor with andengine. when i create a body using the PhysicsEditorExtension, the body and the sprite have different positions. The origin of the Sprite is the center of the body. How can i solve it?

  21. I using Android Studio! When i import the project, a message about the missing gradle appears. I dont know what i can do. Please. Help!

    • Hi Ze,

      thank you for your comment. Unfortunately I don’t have the resources to work on this project anymore. Therefore it does support neither android studio nor the anchor center branch of AndEngine.

      Best regards,

Leave a Reply to Johannes Borchardt Cancel reply

Your email address will not be published.


© 2024 Droid-Blog

Theme by Anders NorenUp ↑