Skip to content

Commit 00c7b1d

Browse files
committed
Destroy on reset!
1 parent d8c0648 commit 00c7b1d

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/gameobjects/GameObject.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,7 @@ var GameObject = new Class({
705705
this.body = undefined;
706706
}
707707

708-
if (this.hasPostPipeline)
709-
{
710-
var pipelines = this.postPipelines;
711-
712-
for (var i = 0; i < pipelines.length; i++)
713-
{
714-
pipelines[i].destroy();
715-
}
716-
}
708+
this.resetPostPipeline(true);
717709

718710
// Tell the Scene to re-sort the children
719711
if (!fromScene)

src/gameobjects/components/Pipeline.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ var Pipeline = {
310310
},
311311

312312
/**
313-
* Resets the WebGL Post Pipelines of this Game Object.
313+
* Resets the WebGL Post Pipelines of this Game Object. It does this by calling
314+
* the `destroy` method on each post pipeline and then clearing the local array.
314315
*
315316
* @method Phaser.GameObjects.Components.Pipeline#resetPostPipeline
316317
* @webglOnly
@@ -322,6 +323,13 @@ var Pipeline = {
322323
{
323324
if (resetData === undefined) { resetData = false; }
324325

326+
var pipelines = this.postPipelines;
327+
328+
for (var i = 0; i < pipelines.length; i++)
329+
{
330+
pipelines[i].destroy();
331+
}
332+
325333
this.postPipelines = [];
326334
this.hasPostPipeline = false;
327335

0 commit comments

Comments
 (0)