I need to make that objects fall from the top of the screen random intervals and positions. Here's my code where I create lot of objects and add them to ArrayList
private void createBalls() {
BodyDef ballBodyDef = new BodyDef();
ballBodyDef.type = BodyDef.BodyType.DynamicBody;
CircleShape shape = new CircleShape();
shape.setRadius(10/Constants.PPM);
shape.setPosition(new Vector2(w/4/ Constants.PPM, 5));
FixtureDef fd = new FixtureDef();
fd.density = 1;
fd.friction = 0.5f;
fd.restitution = 0.5f;
fd.shape = shape;
do {
float rand = MathUtils.random(-2.0f, 2f);
shape.setPosition(new Vector2(w/4/ Constants.PPM + rand, 5));
fd.shape = shape;
bodyArrayList.add(world.createBody(ballBodyDef));
bodyArrayList.get(bodyArrayList.size() - 1).createFixture(fd);
} while (bodyArrayList.size() < 100);
shape.dispose();
}
this code works fine (except that all objects fall at single time). So is it possible to make that objects would fall at different time?