So ideally a function will start a onscreen timer, it will keep track of how long it’s been on until a button is touched.
How exactly can this be done?
So ideally a function will start a onscreen timer, it will keep track of how long it’s been on until a button is touched.
How exactly can this be done?
Inside your function to start the timer, save the current time to a variable and then later when the user pushes the button, get the current time again and subtract the saved time. This will give you the amount of time passed in seconds.
Example:
local startTime local function beginTimer() startTime = os.time() --rest of your code end ...later when user touches button... local function onButtonRelease() local timeElapsed = os.time() - startTime --rest of your code end
Thanks for the advice. However, ideally the elapsed time will be displayed on the screen until the button. So it’d almost need to repeat a function displaying the time until a button is pressed.
try googling - “corona sdk tutorial time”
there is a tut done in the blog re time - it might be of some help.
T.
Inside your function to start the timer, save the current time to a variable and then later when the user pushes the button, get the current time again and subtract the saved time. This will give you the amount of time passed in seconds.
Example:
local startTime local function beginTimer() startTime = os.time() --rest of your code end ...later when user touches button... local function onButtonRelease() local timeElapsed = os.time() - startTime --rest of your code end
Thanks for the advice. However, ideally the elapsed time will be displayed on the screen until the button. So it’d almost need to repeat a function displaying the time until a button is pressed.
try googling - “corona sdk tutorial time”
there is a tut done in the blog re time - it might be of some help.
T.