Posted By

S_Park on 08/06/10


Tagged

object timer


Versions (?)

Timer Object


 / Published in: Processing
 

URL: http://www.learningprocessing.com/examples/chapter-10/example-10-5/

  1. // Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 10-5: Object-oriented timer class Timer { int savedTime; // When Timer started int totalTime; // How long Timer should last Timer(int tempTotalTime) { totalTime = tempTotalTime; } // Starting the timer void start() { // When the timer starts it stores the current time in milliseconds. savedTime = millis(); } // The function isFinished() returns true if 5,000 ms have passed. // The work of the timer is farmed out to this method. boolean isFinished() { // Check how much time has passed int passedTime = millis()- savedTime; if (passedTime > totalTime) { return true; } else { return false; } } }

Report this snippet  

You need to login to post a comment.