Skip to content

Commit cb5b12e

Browse files
committed
The GameObject destroy event is now emitted at the start of the destroy process, before things like the body or input managers have been removed, so you're able to use the event handler to extract any information you require from the GameObject before it's actually disposed of. Previously, the event was dispatched at the very end of the process.
1 parent 8d7ed97 commit cb5b12e

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ A special mention must go to @orblazer for their outstanding assistance in helpi
9393
* Triangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
9494
* Triangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
9595
* Triangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
96+
* The GameObject `destroy` event is now emitted at the start of the destroy process, before things like the body or input managers have been removed, so you're able to use the event handler to extract any information you require from the GameObject before it's actually disposed of. Previously, the event was dispatched at the very end of the process.
9697

9798

9899

src/gameobjects/GameObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ var GameObject = new Class({
331331
this.preDestroy.call(this);
332332
}
333333

334+
this.emit('destroy', this);
335+
334336
var sys = this.scene.sys;
335337

336338
sys.displayList.remove(this);
@@ -363,8 +365,6 @@ var GameObject = new Class({
363365

364366
this.scene = undefined;
365367

366-
this.emit('destroy');
367-
368368
this.removeAllListeners();
369369
}
370370

0 commit comments

Comments
 (0)