Corona SDK timer countUp speeds up when button is touch? I do have 15 question in my game and everytime the answer is being touch the timer countUp speeds up everytime it goes to the another question…
Here is my button touch event
buttonTouched = function(event) local t = event.target local id = t.id if event.phase == "began" and touchEnabled == true then display.getCurrentStage():setFocus( t ) t.isFocus = true if id == "answer" then t.alpha = 0.6 else t.xScale = 0.9 t.yScale = 0.9 end elseif t.isFocus then if event.phase == "ended" then display.getCurrentStage():setFocus( nil ) t.isFocus = false if id == "answer" then t.alpha = 1 else t.xScale = 1 t.yScale = 1 end -- Check that touch finished in the button. local b = t.contentBounds if event.x \>= b.xMin and event.x \<= b.xMax and event.y \>= b.yMin and event.y \<= b.yMax then utils.playSound("select") if id == "answer" then if timer\_trans ~= nil then transition.cancel(timer\_trans) timer\_trans = nil end if result\_trans ~= nil then transition.cancel(result\_trans) result\_trans = nil end if label\_result ~= nil then display.remove(label\_result) label\_result = nil end -- Show some text that we can transition label\_result = display.newText({parent=uiGroup, text="", font=easyFont, fontSize=75}) label\_result.anchorX = 0 label\_result.x = label\_question.x - 540 label\_result.y = label\_question.y + 400 if t.index == questions[onQuestion].answer then label\_result.text = "Correct!" label\_result:setFillColor(0,0.6,0) utils.playSound("score") updateScore(1) else label\_result.text = "Incorrect..." label\_result:setFillColor(0.8,0,0) utils.playSound("incorrect") end result\_trans = transition.to(label\_result, {time=1600, alpha=0.1, y=label\_result.y-18,tag="transTag", onComplete=function() display.remove(label\_result) label\_result = nil end}) -- Now create the next quesiton createQuestion() end end end end return true end function startTimer() clockTimer = timer.performWithDelay(1000,doCountUp,gameTime) end function doCountUp() currentTime = countUpText.text currentTime = currentTime +1 countDownText.text = currentTime if(currentTime == 0) then countUpText.text = currentTime startTimer() end end