Recommendation for handling multiple groups in a scene

I have a “scene1” with multiple display groups:

[lua]for i = 1, 10 do
myGroups[i] = display.newGroup()
end[/lua]

My “scene2” has multiple ImageGroups:

[lua] igPlayfield = display.newImageGroup(imageSheet)
igBall = display.newImageGroup(imageSheet)
igItems = display.newImageGroup(imageSheet)[/lua]

When gotoScene(“scene2”) is called from scene1, scene2’s images appear over scene1, since none of these images are inserted into each scene’s view. I do understand why that is occuring.

My question is… what is the recommended way to handle a scene with multiple display groups and/or image groups, so that gotoScene transition will work correctly? Some of these image groups are displayed on the screen at the same time.

thanks [import]uid: 114363 topic_id: 31551 reply_id: 331551[/import]

You have to remove imageSheets manually. [import]uid: 40033 topic_id: 31551 reply_id: 126056[/import]

Thanks for the reply, but I don’t think that answers my question.

If I have 2 scenes, one with groups and one with image groups… both are not using the default “group” group that is defined in scene.lua since i need multiple layers for scene1 and image groups for scene2.

How do you transition from 1 scene to another using gotoScene using scene effects like “fade”, etc? It appears only the default group is being transitioned. Do I insert groups into the default group? Some other preferred way?

Image groups are not the same as groups, so how do I transition back to scene1 when scene2 uses only image groups? If I can insert image groups into the default group, do I lose the performance improvements of image groups?

If a scene has multiple groups and/or image sheets as layers, how do I transition the entire screen?

I’ve used storyboard for my first app, but it was a basic “one group per scene” game. The new game I am working on is a bit more complicated, and I am having difficulty transitioning between 2 scenes.
[import]uid: 114363 topic_id: 31551 reply_id: 126072[/import]

Ok, but are you removing the groups when you change scenes? [import]uid: 40033 topic_id: 31551 reply_id: 126077[/import]

In my adventure game I’m using lots of groups to create layered scenes, and then inserting these groups into the scene group. That allows me to use effects to transition between my scenes with no problems.

For example, in one of my scenes (“rooms” in adventure game parlance), I have a group for the room, a group for the foreground objects, and a Camera which contains both of these groups. I then insert the Camera into the scene group:

[lua]local group = self.view

– Create lots of groups
– Insert them into group Camera

group:insert(Camera) – Insert Camera group into the scene[/lua]

I’m not sure about ImageGroups, as I haven’t used them at all. But this approach allows me to transition without issue.

Hope that helps!

  • David [import]uid: 149111 topic_id: 31551 reply_id: 126079[/import]

@schizoid2k: The link you posted didn’t work. Is this the page you were referring to? Here’sthe actual imageGroups doc page.

From the above documents, I don’t see any reason why an imageGroup couldn’t be inserted into a normal display group; they just can’t be nested, e.g. an imageGroup can’t be inserted into another imageGroup.

In the createScene listener for scene1 and scene2, I would try inserting your groups into self.view (or assign self.view to a local ‘group’ variable, as shown above, and then insert your groups into the ‘group’ variable). This would certainly work for scene1 since they are just display groups. [import]uid: 149111 topic_id: 31551 reply_id: 126108[/import]

Pixin, David,
Thanks for your reply.

@Pixin, no I am not removing the groups when I change scenes. If I do then there is no fade transition. For my “scene1”, I can place the visible group into the scene’s group (and set the other groups to invisible), and that seems to work.

@Pixin, @David
For scene2, it’s a bit harder… i think. I am reading this page.

It says there can be no nested image groups, but I am not sure if you can place an image group into a display group successfully. Even if you can, does performance suffer? I have a *lot* of images moving on the screen in this scene, so I need the performance benefits of image groups.

Maybe someone from CoronaLabs can comment about this? Is there a recommended way to use image groups within storyboard that allows gotoScene transitions?

thanks! [import]uid: 114363 topic_id: 31551 reply_id: 126104[/import]

@David,

Yes, that is the link… I updated my original message so that link now works.

I think after this discussion and thinking about it a bit more, I will insert my groups and image groups into the scene’s view group.

My only concern at this time is whether there really is a performance hit or not when inserting an image group into a display group. I hope someone at CL is reading this and can provide some info about that. I do worry about any performance issue with my game scene, since there is a lot of images moving around at any given time, and I cannot afford to lose any performance gains from image groups.

Thanks! [import]uid: 114363 topic_id: 31551 reply_id: 126111[/import]

You have to remove imageSheets manually. [import]uid: 40033 topic_id: 31551 reply_id: 126056[/import]

Thanks for the reply, but I don’t think that answers my question.

If I have 2 scenes, one with groups and one with image groups… both are not using the default “group” group that is defined in scene.lua since i need multiple layers for scene1 and image groups for scene2.

How do you transition from 1 scene to another using gotoScene using scene effects like “fade”, etc? It appears only the default group is being transitioned. Do I insert groups into the default group? Some other preferred way?

Image groups are not the same as groups, so how do I transition back to scene1 when scene2 uses only image groups? If I can insert image groups into the default group, do I lose the performance improvements of image groups?

If a scene has multiple groups and/or image sheets as layers, how do I transition the entire screen?

I’ve used storyboard for my first app, but it was a basic “one group per scene” game. The new game I am working on is a bit more complicated, and I am having difficulty transitioning between 2 scenes.
[import]uid: 114363 topic_id: 31551 reply_id: 126072[/import]

Ok, but are you removing the groups when you change scenes? [import]uid: 40033 topic_id: 31551 reply_id: 126077[/import]

In my adventure game I’m using lots of groups to create layered scenes, and then inserting these groups into the scene group. That allows me to use effects to transition between my scenes with no problems.

For example, in one of my scenes (“rooms” in adventure game parlance), I have a group for the room, a group for the foreground objects, and a Camera which contains both of these groups. I then insert the Camera into the scene group:

[lua]local group = self.view

– Create lots of groups
– Insert them into group Camera

group:insert(Camera) – Insert Camera group into the scene[/lua]

I’m not sure about ImageGroups, as I haven’t used them at all. But this approach allows me to transition without issue.

Hope that helps!

  • David [import]uid: 149111 topic_id: 31551 reply_id: 126079[/import]

@schizoid2k: The link you posted didn’t work. Is this the page you were referring to? Here’sthe actual imageGroups doc page.

From the above documents, I don’t see any reason why an imageGroup couldn’t be inserted into a normal display group; they just can’t be nested, e.g. an imageGroup can’t be inserted into another imageGroup.

In the createScene listener for scene1 and scene2, I would try inserting your groups into self.view (or assign self.view to a local ‘group’ variable, as shown above, and then insert your groups into the ‘group’ variable). This would certainly work for scene1 since they are just display groups. [import]uid: 149111 topic_id: 31551 reply_id: 126108[/import]

Pixin, David,
Thanks for your reply.

@Pixin, no I am not removing the groups when I change scenes. If I do then there is no fade transition. For my “scene1”, I can place the visible group into the scene’s group (and set the other groups to invisible), and that seems to work.

@Pixin, @David
For scene2, it’s a bit harder… i think. I am reading this page.

It says there can be no nested image groups, but I am not sure if you can place an image group into a display group successfully. Even if you can, does performance suffer? I have a *lot* of images moving on the screen in this scene, so I need the performance benefits of image groups.

Maybe someone from CoronaLabs can comment about this? Is there a recommended way to use image groups within storyboard that allows gotoScene transitions?

thanks! [import]uid: 114363 topic_id: 31551 reply_id: 126104[/import]

@David,

Yes, that is the link… I updated my original message so that link now works.

I think after this discussion and thinking about it a bit more, I will insert my groups and image groups into the scene’s view group.

My only concern at this time is whether there really is a performance hit or not when inserting an image group into a display group. I hope someone at CL is reading this and can provide some info about that. I do worry about any performance issue with my game scene, since there is a lot of images moving around at any given time, and I cannot afford to lose any performance gains from image groups.

Thanks! [import]uid: 114363 topic_id: 31551 reply_id: 126111[/import]