Advertisement
Guest User

Bobby's Corona SDK Timer Testing

a guest
Jul 26th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local background = display.newImage( "world.jpg", display.contentCenterX, display.contentCenterY )
  2.  
  3. local Number = 0
  4.  
  5. local Timer = display.newText( Number, display.contentCenterX, display.contentCenterY, native.systemFont, 100 )
  6. Timer:setFillColor( 1,1,1 )
  7.  
  8. local NumberAdd = function ()
  9. Number = Number + 0.1
  10. Timer.text = Number
  11. print("Add 0.1")
  12. end
  13.  
  14. local TimerLoops = timer.performWithDelay(100,NumberAdd,0)
  15.  
  16. local RunMode = true
  17.  
  18. function StopOrStart()
  19.  
  20. if RunMode == true then
  21. timer.pause(TimerLoops)
  22. RunMode = false
  23. else
  24. timer.resume(TimerLoops)
  25. RunMode = true
  26. end
  27. end
  28.  
  29. TouchBtn = function (event)
  30. if event.phase == "began"
  31. then StopOrStart()
  32. end
  33. end
  34.  
  35. local ControlBtn = display.newImageRect("Btn.png", 70, 40 )
  36. ControlBtn.x = display.contentCenterX
  37. ControlBtn.y = 430
  38. ControlBtn:addEventListener ("touch", TouchBtn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement