How can I spawn images every 5 seconds?

How can I spawn images every 5 seconds?

local function spawnImage()

     – your code to create the image

end

timer.performWithDelay(5000, spawnImage, 0)

every 5000 milliseconds (5 seconds) it will call your spawnImage().  The 0 on the end says to do it forever.

Rob

oh ok thanks wow I am such a rookie. I know how to delay functions… Just didn’t know that you could loop that. I should of read the timer.perfomWithDelay syntax. Thanks!!

oh Rob how can I remove this function when going to a different scene?

local function spawnImage() -- your code to create the image end local myTimer = timer.performWithDelay(5000, spawnImage, 0) -- in your exit scene or whatever... timer.cancel( myTimer ) myTimer = nil

:wink:

hmm didn’t work “attempt to index a nil value”

edit… 

I just did 

local myTimer

then did 

myTimer = 

thanks!

local function spawnImage()

     – your code to create the image

end

timer.performWithDelay(5000, spawnImage, 0)

every 5000 milliseconds (5 seconds) it will call your spawnImage().  The 0 on the end says to do it forever.

Rob

oh ok thanks wow I am such a rookie. I know how to delay functions… Just didn’t know that you could loop that. I should of read the timer.perfomWithDelay syntax. Thanks!!

oh Rob how can I remove this function when going to a different scene?

local function spawnImage() -- your code to create the image end local myTimer = timer.performWithDelay(5000, spawnImage, 0) -- in your exit scene or whatever... timer.cancel( myTimer ) myTimer = nil

:wink:

hmm didn’t work “attempt to index a nil value”

edit… 

I just did 

local myTimer

then did 

myTimer = 

thanks!