Every Clock component has an internal Timer that whenever it goes off, calls the Clock.Timer event shown in the image above. The Timer will go off after some amount of time specified in the Clock's Properties on the Designer Screen which is measured in milliseconds. TimerInterval can be adjusted to make the Timer go off after different amounts of time. TimerInterval can be found in the Clock's Properties on the Designer Screen. It takes in a number that specifies the number of milliseconds between each time the Clock.Timer event is called.
In games, we often use the Clock.Timer event to tell sprites when to move. We also can use the Timer event to specify when the user has run out of time to finish the game.
We've seen before that sprites have a Speed. Speed is measured in pixels. Sprites also have an Interval. Interval is measured in milliseconds.
Internally, whenever a sprite's Interval goes off, it will be moved speed amount of pixels across the screen in the direction that its heading is pointing. So the sprite is moving at (Sprite.Speed / Sprite.Interval ) pixels/ms. Let's look at this example:
For additional help using animation in App Inventor, check out the reference documentation here .
For more practice using the Clock component and learning about how to use the sprites on a timer, complete the GetTheGold app using the tutorial below.
App Exploration: GetTheGold