Timer In Corona

Hey,

I am currently developing an app in which the game is being timed by a timer. How would I be able to stop and start the timer as well as clear it? Also how would I stop it upon hitting a object…i.e ground?

Many Thanks,
Matt [import]uid: 19514 topic_id: 5354 reply_id: 305354[/import]

Can you describe a bit more what exactly you are trying to do? Depending on what exactly you are doing you may not want a timer, and instead keep track of time in some other event listener by checking system.getTimer()

Assuming you do in fact want to use a timer, take a look at this thread:
http://developer.anscamobile.com/forum/2010/12/24/new-pauseresume-timers-and-table-hold-all-active-timers [import]uid: 12108 topic_id: 5354 reply_id: 17859[/import]

I want to start the timer when the app starts and then stops the timer when it hits an object. Is there a way to do this without a 3rd party module?

Thanks,
Matt [import]uid: 19514 topic_id: 5354 reply_id: 17862[/import]

When you say “start the timer” do you mean a visible display showing the time? In that case you would set a listener for “enterFrame” and update the time display in the listener function.

Regardless of whether or not you want a time display, you should use system.getTimer() to keep track of how long the app’s been running. At the start of your code store the time in some variable, and then later you can subtract the start time from system.getTimer() to find out how long the app has been running. [import]uid: 12108 topic_id: 5354 reply_id: 17887[/import]