Jump to content

Calling Group.Destroy() doesn't properly remove children buttons


jflowers45
 Share

Recommended Posts

Based on the documentation I assumed that if I destroy a group, all children will be destroyed.  This doesn't seem to be the case with buttons.

 

I've created as simple an example as possible at the url below.  Click 'show scoreboard' - this creates a group, creates a button, adds button to group.

 

Then, try the two 'hide scoreboard' buttons.  They each have different callbacks - one of the callbacks just destroys the group.  The other one destroys the button first, then destroys the group.

 

After you call the one that only destroys the group, you can see the error below related to the mouse pointer.

 

http://www.flashysubstance.com/phaserGroupDestroy/

 

Anyone have any ideas?  

 

 

  1. Uncaught TypeError: Cannot read property 'visible' of null phaser.js:12505
    1. Object.defineProperty.getphaser.js:12505
    2. Phaser.InputHandler.checkPointerOverphaser.js:17151
    3. Phaser.Pointer.movephaser.js:16015
    4. Phaser.Mouse.onMouseMovephaser.js:15348
    5. _onMouseMove
Link to comment
Share on other sites

Group.destroy has a boolean parameter: destroyChildren which is false by default, but in this case needs to be true.

 

If that's not available in the version of Phaser you're using then I'm sorry, it's hard for me to keep track when things were added! Also in 1.2 I did quite a lot of work on this today, see this commit:

 

https://github.com/photonstorm/phaser/commit/7e12075be142e91193a0bd00d7cc0f33869d7e93

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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