Stoppable Timer

Материал из Поле цифровой дидактики

This tutorial explains how to make a stoppable timer.

Programming

Three variables are needed:

  • customtimer — the custom timer
  • timestopped — the timer to be incremented while the custom timer is paused
  • stopped? — a boolean that determines whether the custom timer is paused

Three broadcasts are used:

  • "reset" — resets all counters
  • "stop" — pauses the custom timer
  • "start" — starts the custom timer
whenclickedbroadcastresetonlyincludethisifitislikedthatthetimerberesetuponthegreenflagbeingclickedforeverifstopped?=1thenifthetimerisstoppedsettimeStoppedtotimer-customtimerthetimestoppedisequaltothevalueofthetimerminusthevalueofthecustomtimerelseifthetimerisnotstoppedsetcustomtimertotimer-timestoppedthecustomtimer'svalueisequaltothetimer'svalueminusthetimestoppedendendwhenIreceiveresetresetallcounterswithoutdisturbing"isStopped?"resettimersetcustomtimerto0settimestoppedto0whenIreceivestopsetstopped?to1havethetimerbestoppedwhenIreceivestartsetstopped?to0havethetimerbeunstopped

Example Uses

A few possible uses for a stoppable timer include:

  • A racing game
  • Timed events
  • Pausing while using a timer

ja:停止できるタイマー