1

In my Box2D world, I have a ground and a Dynamic Object.

enter image description here

The ground is initially created as a box:

Vec2 gravity = new Vec2(0.0f, 10.0f);
world = new World(gravity);
world.setWarmStarting(true);

BodyDef groundBodyDef = new BodyDef();
groundBodyDef.type = BodyType.STATIC;
groundBodyDef.position.set(0, TOTAL_HEIGHT);

PolygonShape bottomShape = new PolygonShape();
bottomShape.setAsBox(TOTAL_WIDTH, GROUND_HEIGHT);

Body groundBody = world.createBody(groundBodyDef);
groundBody.createFixture(bottomShape, 0.0f);

I would like to add random holes in the ground:

enter image description here

Is it possible to remove parts of the ground in order to make holes in it, or should I remove the existing ground and then add separate "grounds" according to the number of holes I have?

Majid Laissi
  • 19,188
  • 19
  • 68
  • 105

0 Answers0