0

I'm using JBox2d with json to add the bodies from a seprate file, in this case "game_shapes.json".

It successfully adds the FIRST body of the json file, into the Bodies List, and shows it on the screen no probs.

I try to loop through all of the loaded bodies from the json file, but only seems to will be adding the first body from the file.

Init:

Jb2dJson json = new Jb2dJson();
      StringBuilder errorMsg = new StringBuilder();

      world = json.readFromFile("res/game_shapes.json", errorMsg);

      world.createBody(new BodyDef());
      bodies.add(world.getBodyList());
      Body bds = world.getBodyList();

      int bdCount = world.getBodyCount();
      bodies.add(bds);
      for(int i = 1; i < bdCount; i++) {
          Body temp = bds.getNext();
          bodies.add(temp);
          System.out.println(temp);
      }
Kevin Jensen Petersen
  • 423
  • 2
  • 22
  • 43

0 Answers0