Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement