Exemplo n.º 1
0
 private static Filter newContactFilter(short categoryBits, short groupIndex, short maskBits) {
   Filter filter = new Filter();
   filter.categoryBits = categoryBits;
   filter.groupIndex = groupIndex;
   filter.maskBits = maskBits;
   return filter;
 }
Exemplo n.º 2
0
 // 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);
   }
 }
Exemplo n.º 3
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);
   }
 }
Exemplo n.º 4
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));
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
  @Override
  protected void initBody(final World world, final Rectangle bounds) {
    super.initBody(world, bounds);

    // By default in character class, category = player and mask = ground
    Filter filter = body.getFixtureList().get(0).getFilterData();
    filter.categoryBits = B2DVars.ENEMY_MASK;
    filter.maskBits = B2DVars.GROUND_MASK | B2DVars.PROJECTILE_MASK | B2DVars.PLAYER_MASK;
    body.getFixtureList().get(0).setFilterData(filter);
  }
Exemplo n.º 7
0
  /** Kill the enemy */
  public void kill() {
    state = State.BUMP;
    stateTime = 0f;

    // Now don't collide with player or projectile anymore
    // He is dead, but we can't remove it now until animation is done
    Filter filter = body.getFixtureList().get(0).getFilterData();
    filter.categoryBits = B2DVars.ENEMY_MASK;
    filter.maskBits = B2DVars.GROUND_MASK;
    body.getFixtureList().get(0).setFilterData(filter);
  }
Exemplo n.º 8
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);
  }
Exemplo n.º 9
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);
     }
   }
 }
Exemplo n.º 10
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;
 }