Nested group question...

Hi,

is it possible to nest groups, like for example:


Group1 = Background Stuff

Group2 = Enemies

Group3 = Effects

CharacterGroup = An array of groups

Now an enemy character sprite is created, a shadow image for it and a healthbar image. All three are inserted into

CharacterGroup[1]

Now more enemies,shadows and healthbar images are created the same way and are put into CharacterGroup[2] and so on…

Later all CharacterGroup[x] enemies are put inside the Group2


If this is possible, can I move the Enemies like CharacterGroup[2] with transition.to? (So an enemy, his shadow and healthbar will move together with only one transition.to call)

And if so, what do I have to do to get the screen coordinates right for the movement, because groups behavior is a little bit “strange”? I couldn’t find any info on this kind of nesting and group movement.

Any help welcome!

Thank you

Daniela

Yes, you can nest groups, unless you need physics.   Everything that needs to interact with physics, needs to be in the same group.

Thank you! I got this all working now but I wonder how to work with the right coordinates for the “group”-characters because the group xCoordinates and yCoordinates are driving me crazy here :slight_smile: Is there a good tutorial on how to work with groups the way we normally are working with other display objects? All I can find is about group layering and moving child images inside groups but nothing about working with groups like images… positioning them on the screen and so on.

@Rob

I might be wrong, but I think objects from different groups can interact physically with each other, as long as you move the diplay.objects and not the groups.

Yes, objects in different groups can interact with each other… the confusion for some new users comes when they put physics objects in different groups and then shift the x/y position of those groups independently of the others. This will “break” collision detection… thus, always keep the groups at the same coordinates.

Brent

Thanks for the clarification Brent.  The OP’s question, transition.to can move groups. 

Yes, you can nest groups, unless you need physics.   Everything that needs to interact with physics, needs to be in the same group.

Thank you! I got this all working now but I wonder how to work with the right coordinates for the “group”-characters because the group xCoordinates and yCoordinates are driving me crazy here :slight_smile: Is there a good tutorial on how to work with groups the way we normally are working with other display objects? All I can find is about group layering and moving child images inside groups but nothing about working with groups like images… positioning them on the screen and so on.

@Rob

I might be wrong, but I think objects from different groups can interact physically with each other, as long as you move the diplay.objects and not the groups.

Yes, objects in different groups can interact with each other… the confusion for some new users comes when they put physics objects in different groups and then shift the x/y position of those groups independently of the others. This will “break” collision detection… thus, always keep the groups at the same coordinates.

Brent

Thanks for the clarification Brent.  The OP’s question, transition.to can move groups.