@Override
 public void exit() {
   if (mp3Player != null) {
     mp3Player.exit();
   }
   super.exit();
 }
Exemplo n.º 2
0
  protected void nativeMouseEvent(com.jogamp.newt.event.MouseEvent nativeEvent, int peAction) {
    int modifiers = nativeEvent.getModifiers();
    int peModifiers =
        modifiers
            & (InputEvent.SHIFT_MASK
                | InputEvent.CTRL_MASK
                | InputEvent.META_MASK
                | InputEvent.ALT_MASK);

    int peButton = 0;
    if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
      peButton = PConstants.LEFT;
    } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) {
      peButton = PConstants.CENTER;
    } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) {
      peButton = PConstants.RIGHT;
    }

    if (PApplet.platform == PConstants.MACOSX) {
      // if (nativeEvent.isPopupTrigger()) {
      if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        peButton = PConstants.RIGHT;
      }
    }

    int peCount = 0;
    if (peAction == MouseEvent.WHEEL) {
      peCount =
          nativeEvent.isShiftDown()
              ? (int) nativeEvent.getRotation()[0]
              : (int) nativeEvent.getRotation()[1];
    } else {
      peCount = nativeEvent.getClickCount();
    }

    window.getCurrentSurfaceScale(currentPixelScale);
    int sx = (int) (nativeEvent.getX() / currentPixelScale[0]);
    int sy = (int) (nativeEvent.getY() / currentPixelScale[1]);
    int mx = sx - (int) offsetX;
    int my = sy - (int) offsetY;

    if (presentMode) {
      if (peAction == KeyEvent.RELEASE
          && 20 < sx
          && sx < 20 + 100
          && screenRect.height - 70 < sy
          && sy < screenRect.height - 20) {
        //        System.err.println("clicked on exit button");
        //      if (externalMessages) {
        //        System.err.println(PApplet.EXTERNAL_QUIT);
        //        System.err.flush();  // important
        //      }
        //        animator.stop();
        sketch.exit();
        //        window.destroy();
      }

      if (mx < 0 || sketchWidth < mx || my < 0 || sketchHeight < my) {
        return;
      }
    }

    //    if (!graphics.is2X() && 1 < hasSurfacePixelScale[0]) {
    //      x /= 2;
    //      y /= 2;
    //    }

    MouseEvent me =
        new MouseEvent(
            nativeEvent, nativeEvent.getWhen(), peAction, peModifiers, mx, my, peButton, peCount);

    sketch.postEvent(me);
  }
Exemplo n.º 3
0
  public static void drawVisuals() {
    // play button
    int pbx = 300;
    int pby = 400;
    // high score button
    int hx = 230;
    int hy = 500;
    // settings button
    int sx = 270;
    int sy = 600;
    // quit button
    int qx = 230;
    int qy = 700;
    // back button
    int bx = 50;
    int by = 50;

    if (splash) {
      // LOGO
      counter = counter + 1;
      if (counter < 10) parent.image(splash1, 115, 100);
      else if (counter < 20) parent.image(splash2, 115, 100);
      else if (counter < 30) parent.image(splash3, 115, 100);
      else if (counter < 40) parent.image(splash2, 115, 100);
      else if (counter < 50) parent.image(splash1, 115, 100);
      else {
        counter = 0;
        parent.image(splash1, 115, 100);
      }

      // MENU BUTTONS-------------------------

      // PLAY BUTTON
      parent.image(playbutton, pbx, pby);
      if (parent.mouseX > pbx
          && parent.mouseX < pbx + 200
          && parent.mouseY > pby
          && parent.mouseY < pby + 55) {
        parent.image(playbutton2, pbx, pby);
        if (parent.mousePressed) {
          if (mainClass.splash) {
            mainClass.alive = true;
            mainClass.splash = false;
          }
        }
      }

      // SETTING BUTTON
      parent.image(settingbutton, sx, sy);
      if (parent.mouseX > sx
          && parent.mouseX < sx + 250
          && parent.mouseY > sy
          && parent.mouseY < sy + 55) {
        parent.image(settingbutton2, sx, sy);
        if (parent.mousePressed) {
          splash = false;
          settings = true;
        }
      }

      // HIGHSCORE BUTTON
      parent.image(highscorebutton, hx, hy);
      if (parent.mouseX > hx
          && parent.mouseX < hx + 320
          && parent.mouseY > hy
          && parent.mouseY < hy + 55) {
        parent.image(highscorebutton2, hx, hy);
        if (parent.mousePressed) {
          splash = false;
          highscore = true;
        }
      }

      // QUIT BUTTON
      parent.image(quitbutton, qx, qy);
      if (parent.mouseX > qx + 120
          && parent.mouseX < qx + 230
          && parent.mouseY > qy + 15
          && parent.mouseY < qy + 55) {
        parent.image(quitbutton2, qx, qy);
        if (parent.mousePressed) {
          parent.exit();
        }
      }
      parent.textSize(12);
      parent.text("v1.18 - Tallah Khan-14017609 - Manchester Metropolitan University", 205, 880);
    }
  }