Ejemplo n.º 1
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);
        }
      }
    }
  }
Ejemplo n.º 2
0
 /** Display a tracked user on screen */
 private void trackUser(UserData user) {
   for (int i = 0; i < Joint.NUM_JOINTS; i++) {
     Joint joint = user.getJoint(i);
     dot[i].set(joint.getX(), joint.getY());
   }
 }