Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. private void createBalls() {
  2. BodyDef ballBodyDef = new BodyDef();
  3. ballBodyDef.type = BodyDef.BodyType.DynamicBody;
  4.  
  5. CircleShape shape = new CircleShape();
  6. shape.setRadius(10/Constants.PPM);
  7. shape.setPosition(new Vector2(w/4/ Constants.PPM, 5));
  8.  
  9. FixtureDef fd = new FixtureDef();
  10. fd.density = 1;
  11. fd.friction = 0.5f;
  12. fd.restitution = 0.5f;
  13. fd.shape = shape;
  14.  
  15. do {
  16. float rand = MathUtils.random(-2.0f, 2f);
  17. shape.setPosition(new Vector2(w/4/ Constants.PPM + rand, 5));
  18. fd.shape = shape;
  19.  
  20. bodyArrayList.add(world.createBody(ballBodyDef));
  21. bodyArrayList.get(bodyArrayList.size() - 1).createFixture(fd);
  22. } while (bodyArrayList.size() < 100);
  23.  
  24. shape.dispose();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement