dip
March 19, 2013, 3:43pm
1
Hey guys I need some help. How would I go about setting up a timer countdown from 20 seconds? I have seen some examples of this but as i’m new to coding I never got how it works.
All I have so far is the initial set up to it. If there is a better way to do this then thats better too.
timeBar = display.newImage('timeBar.png', 280) timeLeft = display.newText('20', 175, -2, native.systemFontBold, 14) timeLeft:setTextColor(0)
Any help is greatly appreciated.
dip
March 19, 2013, 11:10pm
2
anyone? any help would be great.
dip
March 19, 2013, 11:10pm
3
anyone? any help would be great.
try this
local time = 60 local function decreaseTime() time = time-1 print(time) end timer.performWithDelay(1000,decreaseTime,60)
Hi Dip,
I have a countdown timer of 10 seconds in my app. This is how I do mine.
[lua]
timerText = display.newText( “”, 420, 180, native.systemFont, 22)
timerText:setTextColor( 255, 255, 255 )
screenGroup:insert( timerText )
function gameOver()
if countDown == 0 then
timeBut:removeEventListener( “touch”, timeBut )
countDown = 0
currentTime = countDown
timerText.text = countDown
timer.performWithDelay(3000, delay_trans)
end
timerText.text = countDown
currentTime = countDown
countDown = countDown - 1
end
countDownTimer = timer.performWithDelay( 1000, gameOver, 11 )
[/lua]
The if countDown == 0 loop, is just what I do next when my clock reaches 0, you do not need use it if you don’t want to
try this
local time = 60 local function decreaseTime() time = time-1 print(time) end timer.performWithDelay(1000,decreaseTime,60)
Hi Dip,
I have a countdown timer of 10 seconds in my app. This is how I do mine.
[lua]
timerText = display.newText( “”, 420, 180, native.systemFont, 22)
timerText:setTextColor( 255, 255, 255 )
screenGroup:insert( timerText )
function gameOver()
if countDown == 0 then
timeBut:removeEventListener( “touch”, timeBut )
countDown = 0
currentTime = countDown
timerText.text = countDown
timer.performWithDelay(3000, delay_trans)
end
timerText.text = countDown
currentTime = countDown
countDown = countDown - 1
end
countDownTimer = timer.performWithDelay( 1000, gameOver, 11 )
[/lua]
The if countDown == 0 loop, is just what I do next when my clock reaches 0, you do not need use it if you don’t want to
Wow thanks guys for helping me.
Wow thanks guys for helping me.