Skip to content

Commit 011ebb5

Browse files
committed
Destroy resorts children and sets invisible
1 parent ed56fbc commit 011ebb5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

v3/src/gameobjects/GameObject.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ var GameObject = new Class({
246246
{
247247
if (this.preDestroy)
248248
{
249-
this.preDestroy();
249+
this.preDestroy.call(this);
250250
}
251251

252252
this.scene.sys.displayList.remove(this);
@@ -261,10 +261,15 @@ var GameObject = new Class({
261261
if (this.body)
262262
{
263263
this.scene.sys.physicsManager.remove(this);
264+
264265
this.body = undefined;
265266
}
266267

268+
// Tell the Scene to re-sort the children
269+
this.scene.sys.sortChildrenFlag = true;
270+
267271
this.active = false;
272+
this.Visible = false;
268273

269274
this.data = undefined;
270275

0 commit comments

Comments
 (0)