chainShape.dispose();
createBoxes();
}
private void createBoxes() {
CircleShape ballShape = new CircleShape();
ballShape.setRadius(RADIUS);
FixtureDef def = new FixtureDef();
def.restitution = 0.9f;
def.friction = 0.01f;
def.shape = ballShape;
def.density = 1f;
BodyDef boxBodyDef = new BodyDef();
boxBodyDef.type = BodyType.DynamicBody;
for (int i = 0; i < BALLSNUM; i++) {
// Create the BodyDef, set a random position above the
// ground and create a new body
boxBodyDef.position.x = -20 + (float) (Math.random() * 40);
boxBodyDef.position.y = 10 + (float) (Math.random() * 15);
Body boxBody = world.createBody(boxBodyDef);
boxBody.createFixture(def);
balls.add(boxBody);
}
ballShape.dispose();
}