Jump to content

Groups and Parents


Recommended Posts

Hey everyone. 

So think of a Garden which contains a Tree which contains an Apple. 

Garden extends State
-Tree extends Group
--Apple extends Group

The problem I am having is with the parent of the apple group. 

In TreeGroup we want to create a new AppleGroup:


this.appleGroup = new AppleGroup(this.game, this);

Well the problem I am having is that firstly I do not want to have a parent yet. I want to create an AppleGroup with all its AppleSprites. But I do not want them on the tree until later.  Can you confirm this is not possible? That a group must always be added to the display list on instantiation?

If parent is ignored from the above code, then I still see my apple. So I guess that my appleGroup is given the world instance.  

The interesting thing though is that in either case, regardless of what I pass as the parent:

this.appleGroup = new AppleGroup(this.game, this);console.log(this.appleGroup.parent) //undefinedthis.appleGroup = new AppleGroup(this.game);console.log(this.appleGroup.parent) //undefined

But I can see my AppleGroup on the canvas. Does anyone know what is happening here?  This problem is regarding my MenuScreen during gameplay. I want to create the Screen as part of the UI Instantiation, so later, I can add/remove it from the UI group.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...