Exemplo n.º 1
0
  private void checkHit() {
    AllMinionState m = (AllMinionState) getOneIntersectingObject(AllMinionState.class);
    SWorld sWorld = (SWorld) getWorld();

    if (m != null) {
      oneUpSound.play();
      CollectPoints cp = new CollectPoints();
      cp.collectLives(1);
      if (getWorld() instanceof MyWorld) {
        MyWorld myWorld = (MyWorld) sWorld;
        myWorld.updatePointScoreboard();
      }
      getWorld().removeObject(this);
    }
  }
Exemplo n.º 2
0
  /** Check whether a hand (of any user) touches the radio. Play radio if it does. */
  public void checkHands() {
    MyWorld world = (MyWorld) getWorld();
    UserData[] users = world.getTrackedUsers();

    for (UserData user : users) {
      Joint rightHand = user.getJoint(Joint.RIGHT_HAND);
      Radio radio = getRadio(rightHand.getX(), rightHand.getY());

      if (radio != null) { // yes, there was a radio
        radio.play(1);
      } else {
        Joint leftHand = user.getJoint(Joint.LEFT_HAND);
        radio = getRadio(leftHand.getX(), leftHand.getY());
        if (radio != null) {
          radio.play(2);
        }
      }
    }
  }