コード例 #1
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
      public void executePlay() {
        println("play");

        isPlaying = true;
        startTime = System.nanoTime();
      }
コード例 #2
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
      public void update() {

        if (isPlaying) {
          // only plays sound for dialog
          if (sMan.eventHappened(getPosInSeconds())) {
            // put sound code here!!!
            sMan.peekNextEvent().execute(getPosInSeconds());
            println(sMan.popEvent());
          }

          // find if previous dialog should still be playing, and if so, play it
          if (sMan.getPreviousPoppedDialog(getPosInSeconds()) != null) {
            sMan.getPreviousPoppedDialog(getPosInSeconds()).execute(getPosInSeconds());
            //          println(sMan.getPreviousPoppedDialog(getPosInSeconds()));
          }
        }

        if (overSlide()) {
          over = true;
        } else {
          over = false;
        }

        if (mousePressed && over) {
          locked = true;
        }
        if (!mousePressed) {
          locked = false;
        }
        if (locked) {
          newspos = constrain(mouseX - sheight / 2, sposMin, sposMax);
        }

        if (abs(newspos - spos) > 1 || isPlaying) {

          // if playback has collided with the end of the timeline, stop playing
          if (isPlaying) {
            if (getPosInSeconds() >= totalTime) {
              executePause();
            }
          }

          if (isPlaying) {
            long estimatedTime = System.nanoTime() - startTime;

            if (estimatedTime / 1000000000 >= 1) {
              // if one second has passed, make a new start time (reset the second timer)
              startTime = System.nanoTime();
              //            println("before spos is " + spos + " time is " + getPosInSeconds());
              spos = incrementSposInSeconds();
              println(
                  "spos is "
                      + spos
                      + " time is "
                      + getPosInSeconds()
                      + " frame is "
                      + getPosInFrames());
            }

          } else {
            spos = spos + (newspos - spos) / loose;
          }
        }
        // if the timeline is NOT playing, create the queue for the events to unfold in order
        if (!isPlaying) {
          sMan.createQueue(getPosInSeconds());
        }
        //      println(getPosInSeconds());

      }