Exemplo n.º 1
0
  public void collisionOccured(CollisionEvent event) {

    Body inputBody = null;
    if (event.getBodyA() == in.getBody()) {
      inputBody = event.getBodyB();
    } else if (event.getBodyB() == in.getBody()) {
      inputBody = event.getBodyA();
    }

    if (inputBody == null) return;

    in.handleWorldInput((KObject) inputBody.getUserData());
  }
Exemplo n.º 2
0
  protected void collisions(Enemy enemy, CollisionEvent event) {
    enemy.onCollision();

    // if the enemy is under the feet of the player, it dies
    if ((event.getPoint().getY() < (enemy.getY() + (enemy.getHeight() / 3)))
        && (event.getPoint().getY() > (Globals.player.getY() + (Globals.player.getHeight() / 3)))
    /*&& (event.getPoint().getX() < (other.getX() - 1))
    && (event.getPoint().getX() > (other.getX()
    		- (other.getWidth()) - 1))*/ ) {
      map.removeEntity(enemy);
      killedEnemySound.play();
      ((Enemy) enemy).stopSound();
      Globals.score++;
    }
    // if the enemy is not killed, the player is hurt
    else {
      if (Globals.score > 0) Globals.score--;
      // pain sound
      Globals.player.getPainSound().play(1f, 0.6f);
      Globals.invulnerable = true;
    }
  }