Beispiel #1
0
  private void addBody(World world, float x, float y, boolean dirt) {
    final BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.StaticBody;
    final Body body = world.createBody(bodyDef);
    body.setTransform(x + 0.5f, y + 0.5f, 0);

    final CircleShape shape = new CircleShape();
    shape.setRadius(0.1f);
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = shape;
    final Fixture fixture = body.createFixture(fixtureDef);
    shape.dispose();
    if (dirt) {
      dirts.add(fixture);
    }
  }
Beispiel #2
0
  private Body addFinish(World world, Vector2 position) {
    final BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.StaticBody;
    final Body body = world.createBody(bodyDef);
    body.setTransform(position.x + offset.x, position.y + offset.y, 0);

    final PolygonShape shape = new PolygonShape();
    shape.setAsBox(0.1f, 0.1f);
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = shape;
    fixtureDef.isSensor = true;
    final Fixture fixture = body.createFixture(fixtureDef);
    fixture.setUserData("finish");
    shape.dispose();
    return body;
  }