How to design and code a Timer in AppLab?

At the risk of oversimplifying…here’s a super simple example that just uses timedLoop


If you want to make this into a game there’s some (read: quite a bit) more work to do.

Also worth noting: this isn’t an app lab thing. It’s a javascript thing. And synchronizing timers is super hard…maybe impossible. So, the typical pattern / mindset is that you should have one timer (and only one) for animation. Set it to whatever delay you like and then write code to do some incremental step at each “tick” of the timer.

Here is another example that shows some bouncing balls: https://studio.code.org/projects/applab/U2n8QalI4-I-oYZJ1SMSIg/
Notice that there is one timer on a delay of 41ms (~24 frames per second).

2 Likes