Exemplo n.º 1
0
  /**
   * Instead of using a square shape, we will use a round one.
   *
   * @param body the body created before.
   */
  @Override
  public void createFixturesForBody(Body body) {
    // Use vertices to create fixture shape.
    CircleShape shape = new CircleShape();

    shape.setRadius(getWidth() * GameRenderer.getMPP());

    // Attach fixture
    FixtureDef fd = new FixtureDef();
    fd.shape = shape;
    fd.density = getDensity();
    fd.friction = getFriction();
    fd.restitution = getRestitution();

    // Continue the fixture definition.
    configureFixtureDefinition(fd);

    // We set to the fixture's user data this model, so we can get it later
    // when getting collisions.
    body.createFixture(fd).setUserData(this);

    body.applyForceToCenter(new Vec2(0f, 4f));
  }