I need to display in succession, a 3-2-1 countdown timer. I do not know how to display text for a specified time. Can you help me?
Thanks
UPDATE
I figured it out. Here's the code I used for a 3-2-1 countdown:
1 2 | countdown3 = display.newText("3", 512, 384, "HelveticaNeue", 72) timer.performWithDelay(1500, countdown2, 1) |
Thanks for sharing; glad you got it sorted :)
that's one way to do it.
here's another one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | local countDownNumber = 3 local countdownTxt = display.newText( countDownNumber, 100, 100, native.systemFont , 72) local theTimer function countdown () countdownTxt.text = countDownNumber countDownNumber = countDownNumber - 1 if countDownNumber == -1 then countdownTxt.text = "GO!" timer.cancel (theTimer) -- call your startGame function return end theTimer = timer.performWithDelay(1500, countdown, 1) end countdown () |
views:1557 update:2012/2/8 8:46:10