PDA

View Full Version : Countdown timer object


davidghemer
11-28-2011, 08:10 PM
Apologies if similar objects have been posted before, but here's my version of a countdown timer object.

The main methods are
- displayTime, refreshes the time
- updateTime, occurs approximately every second
- resetTime, resets the time to the default starting time
- setTime, sets the default starting time. Also sets the current time to the default
- stopTimer, stops the timer
- startTimer, starts the timer

I used the "when ... true" event to run updateTime continually when the timer is not stopped.

I used "when key pressed" events to call stopTimer, startTimer and resetTimer.

I called setTime in an initialisation method inside a "when world starts" event.