コード例 #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;
 }
コード例 #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);
   }
 }
コード例 #3
0
ファイル: Entity.java プロジェクト: GDxU/gravity
 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);
   }
 }
コード例 #4
0
ファイル: Player.java プロジェクト: BondarenkoArtur/Gyaya
 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));
 }
コード例 #5
0
ファイル: Turtle.java プロジェクト: linchangjian/LibgdxMario
 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);
 }
コード例 #6
0
ファイル: Enemy.java プロジェクト: Kurukshetran/manga-rush
  @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);
  }
コード例 #7
0
ファイル: Enemy.java プロジェクト: Kurukshetran/manga-rush
  /** 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);
  }
コード例 #8
0
ファイル: OtherBoss.java プロジェクト: xSke/TWINSTICK
  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);
  }
コード例 #9
0
ファイル: Mario.java プロジェクト: B1z/SuperMario
 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);
     }
   }
 }
コード例 #10
0
ファイル: Potion.java プロジェクト: kinkoviktor/OLD-34
 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;
 }