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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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