// Applies filter to ALL fixtures that have been added so far
 public void setFilter(short category, short mask) {
   for (Fixture f : scene.getFixtures()) {
     Filter filter = f.getFilterData();
     filter.categoryBits = category;
     filter.maskBits = mask;
     f.setFilterData(filter);
   }
 }
Esempio n. 2
0
 public void setBits(short cat, short mask) {
   Filter filter = new Filter();
   filter.categoryBits = cat;
   filter.maskBits = mask;
   for (Fixture f : body.getFixtureList()) {
     f.setFilterData(filter);
   }
 }
Esempio n. 3
0
 public void hit() {
   Gyaya.manager.get("audio/music/background.ogg", Music.class).stop();
   Gyaya.manager.get("audio/sounds/uaBArt - Bell.mp3", Sound.class).play();
   playerIsDead = true;
   Filter filter = new Filter();
   filter.maskBits = Gyaya.NOTHING_BIT;
   for (Fixture fixture : b2body.getFixtureList()) fixture.setFilterData(filter);
   b2body.setLinearVelocity(new Vector2(0, 4f));
 }
Esempio n. 4
0
 public void killed() {
   currentState = State.DEAD;
   Filter filter = new Filter();
   filter.maskBits = SuperMario.NOTHING_BIT;
   for (Fixture fixture : b2body.getFixtureList()) {
     fixture.setFilterData(filter);
   }
   b2body.applyLinearImpulse(new Vector2(0, 5f), b2body.getWorldCenter(), true);
 }
Esempio n. 5
0
  public OtherBoss() {
    super("Qubo");

    health = maxHealth = 50;
    size.getTarget().set(2, 2);
    fixture = rectCollision(2, 2);
    Filter filter = new Filter();
    filter.categoryBits = 0x80;
    filter.maskBits = 0x7;
    fixture.setFilterData(filter);
    fixture.setDensity(9999);
    damageOnTouch = 1.5f;

    DomeHat wh = new DomeHat(this, new Vector2(0, 1.2f));
    GameScreen.i.getEntities().add(wh);
  }
Esempio n. 6
0
 public void hit(Enemy enemy) {
   if (enemy instanceof Turtle && ((Turtle) enemy).currentState == Turtle.State.STANDING_SHELL)
     ((Turtle) enemy)
         .kick(
             enemy.b2body.getPosition().x > b2body.getPosition().x
                 ? Turtle.KICK_RIGHT
                 : Turtle.KICK_LEFT);
   else {
     if (marioIsBig) {
       marioIsBig = false;
       timeToRedefineMario = true;
       setBounds(getX(), getY(), getWidth(), getHeight() / 2);
       MarioBros.manager.get("audio/sounds/powerdown.wav", Sound.class).play();
     } else {
       MarioBros.manager.get("audio/music/mario_music.ogg", Music.class).stop();
       MarioBros.manager.get("audio/sounds/mariodie.wav", Sound.class).play();
       marioIsDead = true;
       Filter filter = new Filter();
       filter.maskBits = MarioBros.NOTHING_BIT;
       for (Fixture fixture : b2body.getFixtureList()) fixture.setFilterData(filter);
       b2body.applyLinearImpulse(new Vector2(0, 4f), b2body.getWorldCenter(), true);
     }
   }
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 public void setCategoryFilter(short filterBit) {
   Filter filter = new Filter();
   filter.categoryBits = filterBit;
   fixture.setFilterData(filter);
 }
 // Applies filter to ALL fixtures that have been added so far
 public void setFilter(Filter filter) {
   for (Fixture f : scene.getFixtures()) {
     f.setFilterData(filter);
   }
 }