*edit* I think i have the right thing now but it still doesnt do what i want it to…
The thing is when the app is suspended, the system.getTimer() stays the same, therefore it wont add the correct amount of time to it.
Any ideas, this is what i have:
[code]
local bg = display.newRect( 0, 0, 320, 480 )
local minsText = 0
local secsText = 00
local timeText = display.newText(minsText… “:0” …secsText , 40, 40, “Helvetica”, 24)
timeText:setTextColor(0,0,0)
local Btn = display.newRect( 70, 70, 32, 48 )
Btn:setFillColor (0, 0, 0)
local function updateTime (event)
secsText = secsText + 1
if secsText < 10 then secsText = “0” …secsText elseif secsText > 59 then
secsText = 00
minsText = minsText+1
end
timeText.text = minsText … “:” …secsText
end
Timer = timer.performWithDelay(1000, updateTime, 0)
local function suspend (e)
if( e.type == “applicationSuspend” ) then
print(“applicationSuspend”)
t1 = system.getTimer()
print(“t1 =” … t1)
end
end
function resume (e)
if ( e.type == “applicationResume” ) then
print(“applicationResume”)
local function runningTime(event)
t2 = system.getTimer()
ms = t2 - t1
print("elapsed milliseconds = " … ms)
print (“t2 =” … t2)
local floor = math.floor
secsText = floor(secsText + (ms / 1000))
minsText= floor(minsText + (secsText / 60))
timeText.text = minsText … “:” … secsText
end
timer1 = timer.performWithDelay(1, runningTime, 1)
end
end
Runtime:addEventListener (“system”, suspend)
Runtime:addEventListener (“system”, resume) [import]uid: 67534 topic_id: 22746 reply_id: 90936[/import]