Exemplo n.º 1
0
 private Body createBody(float x, float y, float width, float height, boolean sensor) {
   BodyDef bodyDef = new BodyDef();
   bodyDef.type = BodyDef.BodyType.KinematicBody;
   bodyDef.position.set(new Vector2(x, y));
   bodyDef.allowSleep = true;
   PolygonShape shape = new PolygonShape();
   shape.setAsBox(width / 2, height / 2, new Vector2(0, 0), 0);
   Body _body = WorldUtils.world.createBody(bodyDef);
   Fixture fixture = _body.createFixture(shape, 1.0f);
   fixture.setFriction(0);
   fixture.setSensor(sensor);
   if (!sensor) {
     fixture.setUserData(Constants.POTION_FIXTURE);
   } else {
     fixture.setUserData(Constants.NOT_COLLIDER_FIXTURE);
   }
   Filter filter = new Filter();
   filter.categoryBits = Constants.COLLISION_CREATURE;
   filter.maskBits =
       Constants.COLLISION_GROUND + Constants.COLLISION_CREATURE + Constants.COLLISION_FIELD;
   fixture.setFilterData(filter);
   _body.setUserData(this);
   return _body;
 }