getTimer(id).test.ended() (since beta 0.3)

Tests whether the timer has ended.


[js highlight=”12″ try=”true”]
newText(“start”, “Ready… go!”)
newTimer(“hurry”, 1000)
newButton(“click”, “Click me!”)
.success( newText(“slow”, “Too slow…”).print() )
.failure( newText(“fast”, “Good job!”).print() )

Adds a line of text saying Ready… go! to the screen, starts a 1s timer, adds a button reading Click me!, and waits for a click on the button. If the timer has ended by the time the button is clicked, the text Too slow… is added to the screen, otherwise if the button is clicked within 1s, Good job! appears below it.