Jump to content

Properly Destroy a Group


brentstrandy
 Share

Recommended Posts

I simply want to know the best approach for destroying a group and everything within the group.

According to the documentation:

destroy(destroyChildren, soft)

Destroys this group.

Removes all children, then removes this group from its parent and nulls references.

Unfortunately, I'm still finding that my references return an object - not null or undefined

For reference, here is a simplified look at the object I'm trying to destroy:

class MyObject extends Phaser.Group {
    constructor(game) {
        this.game = game;

        // Creating Phaser sprites and adding them to group
     }

    destroyObject() {
        this.destroy();
    }
}

 

Link to comment
Share on other sites

5 hours ago, brentstrandy said:

Unfortunately, I'm still finding that my references return an object

That's normal. If you have any references to the group itself, you can set them to `null` or let them pass out of scope. When no references remain it will get garbage-collected.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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