How do I display an object for a set time?

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:

countdown3 = display.newText("3", 512, 384, "HelveticaNeue", 72)  
timer.performWithDelay(1500, countdown2, 1)  

This calls the function Countdown2 after 1.5 seconds.

function countdown2 ()  
countdown3.isVisible = false  
countdown2 = display.newText("2", 512, 384, "HelveticaNeue", 72)  
timer.performWithDelay(1500, countdown1, 1)  
end  

This gets rid of the 3 and displays the 2, and calls Countdown1 after 1.5 seconds.

function countdown1 ()  
countdown2.isVisible = false  
countdown1 = display.newText("1", 512, 384, "HelveticaNeue", 72)  
timer.performWithDelay(1500, countdownend, 1)  
end  

This gets rid of the 2 and displays the 1, and calls Countdownend afer 1.5 seconds.

function countdownend()  
countdown1.isVisible = false  
end  

This gets rid of the last display of the countdown.

And that’s how I did my countdown. [import]uid: 48020 topic_id: 21366 reply_id: 321366[/import]

Thanks for sharing; glad you got it sorted :slight_smile: [import]uid: 52491 topic_id: 21366 reply_id: 84599[/import]

that’s one way to do it.
here’s another one:

  
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 ()  
  

cheers
-finefin [import]uid: 70635 topic_id: 21366 reply_id: 84624[/import]