Why GameObjects dont have add child functionality?

Recommended Posts

Question in topic. I think this is pretty useful, its overhead to make a container to have image + text functionality (Button) for example. Or am I missing something?

Edited by mazoku

Share this post

Link to post
Share on other sites
On 1/12/2020 at 6:23 PM, rich said:

It’s more overhead for every single Game Object to be a container. How many buttons does a typical game contain vs. things like bullets, platforms, particles, baddies, power-ups, etc etc.

It sounds like it would be bad practice to use containers in Phaser 3, is that the case? Say I don't nest them at all, just use them to define more complex Game Objects that require layered sprites. So an example would be to have 10 moving sprites, compared to 10 moving containers (with 1 sprite child) (without physics).

Share this post

Link to post
Share on other sites

There's nothing wrong with using Containers in Phaser 3. The example given by mazoku (a UI Button) is a perfect use-case for them. As are multi-part sprites, i.e. complex Game Objects. But if a Container has just a single child, that's when it doesn't usually make sense any more.

Share this post

Link to post
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.