new

new Timer( duration )

Creates a new timer, which lasts for the given duration. The duration is given in milliseconds.

/* Slowly fade the screen to white over 10 seconds. */

// a ten second timer
timer = new Timer( 5_000 )

onEachFrame() do
    fill( :black )
    fill( :white, timer.getPercent() )
end

new Timer( duration, percentDone )

This constructor allows you to specify how far along the timer is, using the 'percentDone' parameter. This is a value from 0.0, which indicates that none of the duration has expired, to 1.0, which indicates the Timer has expired.

There are a number of occasions where it is useful to create a timer for 1 second, which is a third of the way along (for example). This constructor is for those occasions.