Jump to content

Group.add() doesn't add children to display list


jorbascrumps
 Share

Recommended Posts

I created an issue without reading the contribution guide (oops), so I'll pose my question here:

I'm not sure if this is a bug but it definitely seems counter-intuitive to me..

It is possible to use the following snippet to add a `Sprite` to a `Group` and have it shown on-screen:

const group = this.add.group();
group.create(0, 0, 'player');

However, using the following snippet to add a custom `Sprite` does not show the results on-screen:

const playerSprite = new PlayerSprite(/* .. */); // extends Phaser.GameObjects.Sprite
const group = this.add.group();
group.add(playerSprite);

From what I can tell this is because `Group.add()` and `Group.addMultiple()` don't include this line:

this.scene.sys.displayList.add(child);

If this behaviour is intentional, please let me know if I should be using another method. Otherwise, I'd be happy to submit a PR to fix.

I'm using v3.0.0-beta.7

PS - If the powers that be can delete my Github issue, that'd be much appreciated! :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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