Hello. I am new to Corona SDK and LUA so thank you for your help.
I am using the director class, and my code is on a screen.lua page.
When I add the sample code below it kills my program and I get a black screen in the simulator when I switch to this screen. I had the program running by itself previously, and I am now trying to move it into your director class code so I can have various screens in my app.
From testing, the problem appears to be with the timer.
timer.performWithDelay(1000, setupgrid1, 0 )
When I change the timer to just setupgrid1() the function works, but doesn’t repeat obviously.
When I change it to read
timer.performWithDelay(1000, setupgrid1() )
it also works, but doesn’t repeat.
Finally, I tried timer.performWithDelay(1000, setupgrid1(), 0 )
and it works one time, but it does not repeat even though I have added in the 0.
Any suggestions???
Sample of code…
–Set up random grid displays in each square
function setupgrid1 ()
grid1 = math.random(8)
if grid1 == 1
then grid1loc = display.newImage(bkcolor1)
elseif grid1 == 2
then grid1loc = display.newImage(bkcolor2)
elseif grid1 == 3
then grid1loc = display.newImage(bkcolor3)
elseif grid1 == 4
then grid1loc = display.newImage(bkcolor4)
elseif grid1 == 5
then grid1loc = display.newImage(bkcolor5)
elseif grid1 == 6
then grid1loc = display.newImage(bkcolor6)
elseif grid1 == 7
then grid1loc = display.newImage(bkcolor7)
elseif grid1 == 8
then grid1loc = display.newImage(bkcolor8)
end
grid1loc.x = display.stageWidth - 258
grid1loc.y = display.stageHeight - 268
group1:insert(grid1loc)
end
timer.performWithDelay(1000, setupgrid1, 0 ) [import]uid: 15669 topic_id: 6118 reply_id: 306118[/import]