getPercentLeft

.getPercentLeft()

Returns a value, between 1.0 and 0.0. This is based on how far along the Timer is, with 1.0 being when it has just started, and 0.0 being when it has expired.

This is useful for building animations which run during the life of the Timer.

/* 
 * Repeatedly fades in a pink rectangle,
 * whilst shrinking it,
 * over 2 seconds.
 */

timer = new Timer( 2000 )

onEachFrame() do
    if timer.isExpired()
        timer.reset()
    end
    
    fill( :pink )
    
    setColor( :white, timer.getPercent() )
    width  = getScreenWidth()*timer.getPercentLeft()
    height = getScreenHeight()*timer.getPercentLeft()
    fillRect(
            getScreenWidth()/2, getScreenHeight()/2,
            width, height,
            true
    )
end

See also

getPercent