Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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? – NauticalMile Jun 3 '14 at 18:24

use this code. Though you must have got a file named 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();
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.