WaitTimer(id, time[, reset])
idhas reached the specified time. This time is specified in milliseconds. Before this function returns it will reset the specified timer so that you can easily use this function in a loop. You can change this behaviour by setting the optional argument
False. In that case, the timer will not be reset.
WaitTimer() is extremely useful if you want to limit the speed of certain
loops. For instance, if you have a loop that moves a sprite from the
left to the right boundary of the screen, you should add some kind of
limitation so that it does not run faster than it should. This is very
important. Even if the script runs at perfect speed without
you should not forget that there are faster machines than yours. Using
WaitTimer() in your loops will make sure that your application runs on
every system at the same speed.
See Script timing for details.
WaitTimer()returns (defaults to
Truewhich means that the timer will be reset)
StartTimer(1) For k = 0 To 640 DisplaySprite(1, k, 0) WaitTimer(1, 40) NextThe above code scrolls sprite 1 from left to right. After each call to DisplaySprite(),
WaitTimer()is used to ensure that we wait at least 40 milliseconds until the next DisplaySprite(). Thus, this loop will not be executed more than 25 times a second because 40 * 25 = 1000.