Timer

How would I go about resetting a Timer? For example:

local timerLaunch = system.getTimer()

if timerLaunch < 10000 then
imageDisplay = display.newImage( “e4.png”, 0, 0 )
else
if timerLaunch < 15000 then
imageDisplay = display.newImage( “e3.png”, 0, 0 )
else
if timerLaunch < 20000 then
imageDisplay = display.newImage( “e2.png”, 0, 0 )
else

How would I go about resetting the timer to zero at this point?

Thanks,

Chad
[import]uid: 3396 topic_id: 370 reply_id: 300370[/import]

Chad,

given, that your code is part of an event handler, you could do the following

  • calculate your time relative to your “reference time”
 local TimeInApp = system.getTimer()-timerLaunch;
  • change your “if” conditions to s.th. like
 if (TimeInApp \< 10000) then ... 
  • now, whenever necessary, “reset” your “reference time”
 timerLaunch = system.getTimer();

Kind regards,

Andreas Rozek [import]uid: 4331 topic_id: 370 reply_id: 669[/import]