Search code examples
app-inventor

How to create a resetable timer?


On the MIT App Inventor (similar but not the same to Scratch), I need to create a timer that can be reset when an action happens to complete an App. But, I have been unable to find a way to make a resetable timer. Is there a way using this piece of software? This is a link to the App Inventor.

The first 4 blocks are the codes for when the player interacts/clicks one of the 4 colored boxes.

The last block is the code outside of the 4 .Click blocks.

enter image description here enter image description here enter image description here enter image description here enter image description here


Solution

  • Btw. there is a lot of redundancy in your blocks, see Enis' tips here how to simplify this...

    If you want to reset the clock, just set Clock.TimerEnabled = false and then set Clock.TimerEnabled = true again and the clock will restart
    see also the following example blocks (let's assume, you have a clock component and the timer interval is 10 seconds)

    enter image description here

    in the example I reset the clock after 5 seconds and as you can see, the clock starts from the beginning...

    enter image description here

    You can download the test project from here