Lets Build a game Timer PLEASE!!

So i am posting in the forums once again after i am so tired of searching the forums and docs trying to create a simple timer that displays how many seconds you have played the current level for. I would LOVE to use the beebe class for this but cannot seem to figure it out. Here is what i have, after following jon’s tutorial.

local timeCounter = resetTimeCounter()  
  
local timePassed = getCountedTime( timeCounter )  
  
local raceTime = display.newText(timePassed, 0, 0, native.systemFontBold, 35)  

so this displays a zero on my screen but the time does not get refreshed, what do i need to do for this to be accomplished. Or if anyone has a better method for doing displaying a time counter PLEASE i would be so very thankful for your help. This just seems like it should be so simple, and i have wasted alot of time on it. thanks in advance [import]uid: 19620 topic_id: 7733 reply_id: 307733[/import]

In the enterFrame handler, set raceTime.text to the current time. Use the string formatter to make it look nice. You don’t need to do this every frame, just as often as the resolution of your timer requires.
[import]uid: 3953 topic_id: 7733 reply_id: 27742[/import]

ok so this is what i have:

  
local timeCounter = resetTimeCounter()  
  
local timePassed = getCountedTime( timeCounter )  
  
local raceTime = display.newText(timePassed, 0, 0, native.systemFontBold, 35)  
  
local function refreshtime ()  
 raceTime.text = timePassed  
end  
  
Runtime:addEventListener( "enterFrame", refreshtime)  

not sure if this is what you explained but i still dont have any success with this. Also what is the string formatter? i assume it would help my text not look all crazy and shifty as it counts [import]uid: 19620 topic_id: 7733 reply_id: 27802[/import]

I don’t know, if it’s the best way, but in the sample code folder “GettingStarted” you can find a “Timer”! [import]uid: 42078 topic_id: 7733 reply_id: 27989[/import]

Yea i wanted to use the beebe class but i have given up on that, i followed that sample code and i have a timer now that is counting, thanks for the reply [import]uid: 19620 topic_id: 7733 reply_id: 27991[/import]

OK for anyone else that finds this, i figured out how to get the beebe class timer to at least function. No one could ever help me out, so hopefully this benefits someone else…

here is how you should code it :

[code]

local raceTime = display.newText(timePassed, 0, 0, native.systemFontBold, 35)

local timeCounter = resetTimeCounter()

local function refreshtime()
local timePassed = getCountedTime( timeCounter )
raceTime.text = timePassed
end

Runtime:addEventListener( “enterFrame”, refreshtime)

[/code] [import]uid: 19620 topic_id: 7733 reply_id: 28274[/import]