Hi Mikey
Hi All
Can anyone explain how to do something after a specific time has expired and how to measure a time gap?
Timers are a good way to do an operation after a certain time period has elapsed. They can also be set to repeat the operation continuously.
HAC has two types of timers - the Main Timer and Card Timers. The Main Timer can operate even when cards (screens) are changed. Card Timers are controls that can be placed on a card, are invisible, and are only active on that card. Card Timers can be found on the controls section of the toolbar.
Assuming a card timer use this command to make it fire after 2.5 seconds. Place it in your button.
TimerSet(1,1,2500)
Where:
the first parameter is the timer number,
the second parameter is its mode 0 = off, 1 = fire once, 2 = fire repeatedly
the third parameter is the delay in milliseconds.
I am making a reaction timer thats needs a random timer but cannot figure out how the time works or how to get a random number.
The RndFN function returns an integer value between and including the two parameters:-
@ set random time to between 3 to 5 seconds
Put RndFN(3000,5000) into delay
TimerSet(1,1,delay)
My tester game only has one button plus a canvas. When the player presses the button my game should display a random picture after a random time. I know how to display the picture in the canvas but don't understand the random timer part. Also after the piture has appeared how do I measure the gap between that and the canvas being touched.?
Mikey
Elapsed time can be measured using either the TicksFN or MicroSecondsFN functions. TicksFN measures 60th seconds. Note, MicrosSecondsFN is only accurate to milliseconds on an Android device.
In your timer put this code:-
Global startTime
Put MicrosSecondsFN into startTime
In your canvas event put this code:-
Global startTime
Local nowTime
Put MicrosSecondsFN into nowTime
Subtract startTime from nowTime
Malkom