I’m learning Corona but I’ve been developing software in other languages for over a decade (not games, though). I’m in the process of creating a Tower Defense game just for fun in order to learn the SDK.
My question has to do with how to organize object creation/destruction inside the game’s class structure.
For example, the root object is the “level” (as in level1.lua) and that contains a “scene” object. So far this is kind of dictated by Corona if you want to use scenes (I do). If you open the game template project, this is what you get so I’m assuming it’s the suggested best practice for this kind of app.
Question #1
Who should be listening to the enterFrame event? level1 or scene?
Question #2
The blank scene:create() template has a screneGroup variable where they state: “all display objects must be inserted into group”. That’s fine for the hard coded display objects that you instanciate during scene creation but in my case, a ton more objects will be created and destroyed on the fly as the user interacts with the game.
What is the function of this sceneGroup variable?
On a related note the sceneGoup variable is defined as local in the scene:create() function so as soon at that block executes, the reference to it is lost forever. If I need to add more objects to this group after the function has finished executing (which I’m sure happens in 99% of Corona games), why would they have it be a local function?
Question #3
Where should you keep references to your dynamically created display objects? Let’s say I tap a tower and create a popover tower upgrade menu. Where should I keep a reference to it to be able to destroy it after the user taps somewhere else? And where do you store the rest of your display object (towers, creeps, maps, UI, etc).
Note that I’m not particularly looking for actual code (I think I can figure that our by myself reading the docs) but I’m looking for conceptual answers.
Thanks in advance.