I’m trying to get my timer to appear on my top right hand side but I dont see it and I have no errors. Are there more solid tutorials on this?
I used a tut from youtube and its not working all that great:
I added My code:
-- setup timer here local output = display.newText ("0", 0, 0, native.systemFont, 320) output:setTextColor(0, 0, 0) output.anchorX = \_W \* 20 output.anchorY = \_H \* 0.09 local stateText = display.newText("Paused", 0, 0, native.systemFont, 16) stateText:setTextColor(255, 255, 255) stateText.x = \_W \* 0.5 stateText.y = \_H + 10 --Create method to add the settext method to text objects local function addSetText(obj) -- create a cudtom method for setting text function obj:setText(txt, align) local a = align or display.CenterReferencePoint local oldX = self.x local oldY = self.y self.text = txt self:setReferencePoint(a) self.x = oldX self.y = oldY end end -- Add the setText method to the two text objects addSetText(output) addSetText(stateText) local tmr tmr = timer.performWithDelay(500, function(e) output:setText(e.count) if(e.count == 10) then timer.cancel(tmr) tmr = nil stateText:setText("Timer Finished") end end, 10) timer.pause(tmr) local paused = true local function touchHandler(e) if(tmr) then if(e.phase == "ended" or e.phase == "cancelled") then if(paused == false) then timer.pause(tmr) stateText:setText("Paused") paused = true elseif(pauseed == true) then timer.resume(tmr) stateText:setText("Running") paused = false end end end end Runtime:addEventListener("touch", touchHandler)
I gotta admit this example really sucks is there something more quick and easier to implement. I want the timer to start on touch