Hi,
I’m new to lua and corona and I am getting my head around some of the ideas/principles… I have a simple game which I am writing and the code looks something like this:
function dolevel(level)
– Create display objects and layout
…
end
– Accelerometer function
local function accel( event )
– Read the Accelerometer and more the objects / sprites accordingly
– Also does collision detection
…
end
local function frameupdate()
– Do the animation
– Call object:translate as needed to move the sprites / objects
end
local function main()
dolevel(1)
system.setAccelerometerInterval(10)
Runtime:addEventListener( “accelerometer”, accel )
Runtime:addEventListener( “enterFrame”, frameupdate );
end
main()
Now my question is this… In the accelerometer or the enterFrame listeners I can detect if the level has been completed. My question what is the best way to commnicate that with main() so that the 2 EventListeners can be removed, the next level created and the EventListeners added again.
Should I loop in main()? I am guessing that will lots of CPU…
This is more about structure than actual code… Any ideas???
Thanks,
Gary [import]uid: 4415 topic_id: 393 reply_id: 300393[/import]