Some games keep running while you sit back and watch. Here's how you build a clock that does the clicking for you.
Not started yet.
Students will add a Timer node named AutoTimer, set its Wait Time to 1 and turn Autostart on, connect its Timeout signal to a method that adds one to the count, and add an Auto button that starts or stops the timer.
A Timer is a node that rings a signal called Timeout after its Wait Time, and then rings it again and again for as long as it's running.
Connecting Timeout works the same way as connecting a button's Pressed signal, with plus-equals and a method name.
A button that toggles a timer uses if and else, one door for when it's stopped and the other for when it's running.
Adding the Timer but leaving Autostart off and never starting it from code, so nothing ever happens.
Leaving Wait Time at 0 or a tiny number, which makes the count climb too fast to follow. Setting it to 1 means one tick a second.
Misspelling the node name in the code, so the timer can't be found. It must be AutoTimer, with a capital A and a capital T.
When this lesson is done, the scene should show Main with CountLabel, PlusButton, MinusButton, ResetButton, AutoTimer and AutoButton under it, all spelled exactly that way.
Pressing F5 should make the number climb by one every second without any clicks, and the Auto button should stop it and start it again. The number should turn red when it passes 100.
A parent can open Main.cs and compare it to the code in the Watch It Worked, where a timer variable, a timer method and an Auto method have been added to the previous lesson's file.
Optional. Watch one first, then press Add to put it in the Visual Panel for a student.
Read-aloud is not available in this browser. Try Chrome or Safari.
Before You Start
The words this lesson uses. Tap a card to see what it means, then come back to them whenever a question uses one.
Part One
Questions about the story you just read. Pick your answer straight off, or press Find it in the story if you would rather hunt for the sentence first.
Part Two
The word cards are at the top of this page. Look back at them as often as you need, then answer.