getPercent

.getPercent()

Returns the duration left of this Timer, but as a value from 0.0 to 1.0.

If this is fully expired, then 1.0 is always returned. If none of the timer duration has been expired, then this will return 0.0.

This method is useful for animating during the life of the Timer.

/* Fades in a Green screen, over 2 seconds, repeatedly */

timer = new Timer( 2000 )

onEachFrame() do
    if timer.isExpired()
        timer.reset()
    end
    
    fill( :black )
    fill( :green, timer.getPercent() )
end

See also

getPercentLeft