Skip to content

Commit 9ad7aee

Browse files
authored
Merge pull request phaserjs#3304 from rexrainbow/master
Add destroy event of gameobject
2 parents c2f25b3 + baeca90 commit 9ad7aee

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/gameobjects/GameObject.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ var GameObject = new Class({
320320
*/
321321
destroy: function ()
322322
{
323+
// this gameobject had been destroyed
324+
if (this.scene === undefined)
325+
{
326+
return;
327+
}
328+
323329
if (this.preDestroy)
324330
{
325331
this.preDestroy.call(this);
@@ -357,6 +363,8 @@ var GameObject = new Class({
357363

358364
this.scene = undefined;
359365

366+
this.emit('destroy');
367+
360368
this.removeAllListeners();
361369
}
362370

0 commit comments

Comments
 (0)