Phaser: Self destroyed gameobject keeped in Group

Created on 18 Mar 2018  路  2Comments  路  Source: photonstorm/phaser

When call this.destroy() in GameObject which is added in some group, this object is still in the group and require call groupName.remove(gameObject, true /* removeFromScene */);

I think this should be called automaticly when is GameObject.destoy() called ? Or it should be strict like this ?

This cause some diffucilty debug issues, like each function up on this group. When this removed GameObject try access to this.scene property, it will crashed asn undefined property

This is very nicely solved in Phaser CE in destroy compnent when child call this.parent.remove(this)
https://github.com/photonstorm/phaser-ce/blob/29bc2b2d76f432a34fdb36ecc8ee634e0d8fdaf0/src/gameobjects/components/Destroy.js#L37-L56

So it should be somethink like this, here: https://github.com/photonstorm/phaser/blob/d1d8d4c4a2bbcbfbedd3151ce9f3055810de2b83/src/gameobjects/GameObject.js#L305-L369

But problem is, GameObject not have proprty like parrent.

Most helpful comment

Groups are no longer exclusive, a single GameObject can exist in many Groups, so it can't be automatically removed as part of the destroy process. A Group could listen for the destroy event from a child though, and remove if it receives that.

All 2 comments

Groups are no longer exclusive, a single GameObject can exist in many Groups, so it can't be automatically removed as part of the destroy process. A Group could listen for the destroy event from a child though, and remove if it receives that.

This feature is now implemented in the master branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rootasjey picture rootasjey  路  3Comments

MarkSky picture MarkSky  路  3Comments

rexrainbow picture rexrainbow  路  4Comments

Secretmapper picture Secretmapper  路  3Comments

Colbydude picture Colbydude  路  4Comments