Delay

Here is my sample code -

_________________________________________________________________________________

**–countdown begins
local function beginCount()
    local sheetDataCnt = { width =925, height=1172, numFrames=3 }

local imageSheetCnt = graphics.newImageSheet ( “sprites/countDownNum.png”, sheetDataCnt )

local sequenceDataCnt = { { name=“countDown”, start=1, count=3, time=3000 } }

local cntDwn = display.newSprite ( imageSheetCnt, sequenceDataCnt )
cntDwn.x = display.contentCenterX
cntDwn.y = display.contentCenterY
cntDwn.alpha=1
cntDwn:scale (.2,.2)
cntDwn:setSequence (“countDown”)
cntDwn:play()
    
end
  **** beginCount()**

______________________________________________________________________________________________

Im trying to make the above code load in a background image after it completes countdown. So the above code does the following -

shows 3 images 3, 2, 1 respectively. After it gets to 1 i want the app to load in a background image. Can someone give me some ideas on how to make this happen? Im not sure if I need a delay command maybe? or what?

I appreciate it, thanks.
 

You can use the timer.performWithDelay api function:

http://docs.coronalabs.com/api/library/timer/performWithDelay.html

you could do this:

[lua]

**–countdown begins

local function beginCount()

    local sheetDataCnt = { width =925, height=1172, numFrames=3 }

local imageSheetCnt = graphics.newImageSheet ( “sprites/countDownNum.png”, sheetDataCnt )

local sequenceDataCnt = { { name=“countDown”, start=1, count=3, time=3000 } }

local cntDwn = display.newSprite ( imageSheetCnt, sequenceDataCnt )

cntDwn.x = display.contentCenterX

cntDwn.y = display.contentCenterY

cntDwn.alpha=1

cntDwn:scale (.2,.2)

cntDwn:setSequence (“countDown”)

cntDwn:play()

    

end**

begincount()

local function showbackground(event)

     local backgroundimage = display.newImageRect(“background.png”,320,480)

end

timer.perfrormWithDelay(3000,showbackground,1)

[/lua]

I will give it a try!^^

Didnt work for me.  not sure why.

You can use the timer.performWithDelay api function:

http://docs.coronalabs.com/api/library/timer/performWithDelay.html

you could do this:

[lua]

**–countdown begins

local function beginCount()

    local sheetDataCnt = { width =925, height=1172, numFrames=3 }

local imageSheetCnt = graphics.newImageSheet ( “sprites/countDownNum.png”, sheetDataCnt )

local sequenceDataCnt = { { name=“countDown”, start=1, count=3, time=3000 } }

local cntDwn = display.newSprite ( imageSheetCnt, sequenceDataCnt )

cntDwn.x = display.contentCenterX

cntDwn.y = display.contentCenterY

cntDwn.alpha=1

cntDwn:scale (.2,.2)

cntDwn:setSequence (“countDown”)

cntDwn:play()

    

end**

begincount()

local function showbackground(event)

     local backgroundimage = display.newImageRect(“background.png”,320,480)

end

timer.perfrormWithDelay(3000,showbackground,1)

[/lua]

I will give it a try!^^

Didnt work for me.  not sure why.