I'm using Libgdx. I did a simple json file in Physics Body Editor and I don't have any idea how could I import it into my physic world in libgdx.

Any idea will be appreciated.

P.S: Sorry if there are question with the same subject, I didn't find any of them.

  • 1
    \$\begingroup\$ One of the features listed for the Physics Body Editor is a 'Loader provided for LibGDX game framework'. The page I linked to also gives an example of how to use the loader. Isn't this what you're looking for? \$\endgroup\$ Jun 3, 2014 at 18:24

1 Answer 1


use this code. Though you must have got a file named app.java when you downloaded .zip of physics body editor. This code is from that file only which uses .json file from the editor.

// 0. Create a loader for the file saved from the editor. BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));

    // 1. Create a BodyDef, as usual.
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DynamicBody;

    // 2. Create a FixtureDef, as usual.
    FixtureDef fd = new FixtureDef();
    fd.density = 1;
    fd.friction = 0.5f;
    fd.restitution = 0.3f;

    // 3. Create a Body, as usual.
    bottleModel = world.createBody(bd);

    // 4. Create the body fixture automatically by using the loader.
    loader.attachFixture(bottleModel, "test01", fd, BOTTLE_WIDTH);
    bottleModelOrigin = loader.getOrigin("test01", BOTTLE_WIDTH).cpy();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .