Greetings all,
I’m new to Corona/Lua and I’m learning the ropes, so this might be a novice question.
I see that Corona doesn’t support “layers” per se, in terms of rendering objects in the z-index relation of each other. However, in my very brief testing so far, it appears that those objects added to the screen later (as in, further down in the code, or initiated by a function during runtime) are placed in front of those objects that were added to the screen earlier. Is this correct?
If so, can I use Groups to initialize a master “layer” setup as the game begins, and add/subtract objects from them as necessary?
Here’s my theoretical example: upon runtime, before any objects are added to the screen, some groups are set up.
local distant\_background\_Group = display.newGroup()
local closer\_background\_Group = display.newGroup()
local main\_Group = display.newGroup()
local clouds\_Group = display.newGroup()
Initially, no objects are added to any group, although I suppose they could be in this step. More importantly, the groups are initialized to determine their “layer” order. If I’m correct (quite possibly I’m not), those 4 groups would be in a relational z-index to each other, with the “clouds” group in the very front because it was initialized last, and the “distant_background” group in the very back because it was initialized first.
If this practice will work properly – and please correct me if it won’t – will objects added to the scene later, if sorted into the proper group, be rendered in the respective layer? For example, if I use a function to spawn a new object, and I set the parent group to “clouds_Group” within display.newImageRect(), will that object be sorted into the clouds layer, and thus appear in front of all objects contained within “layers” further back, regardless of when they were added to the screen? If I then add a new object to “main_Group”, will it appear behind the clouds, even if some cloud images were added much earlier in game time?
Basically I’m trying to determine a layer management system, without actually having layer functionality.
I’m sure other Corona users have tackled and solved this issue, so please give me your advice. Thank you!
Brent
[import]uid: 9747 topic_id: 2542 reply_id: 302542[/import]