Skip to content

Commit dc5bccc

Browse files
committed
Added purge method to clear out an ObjectPool and finished destroy method.
1 parent bb359fa commit dc5bccc

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

v3/src/gameobjects/pool/ObjectPool.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ var ObjectPool = new Class({
149149
}
150150
},
151151

152+
purge: function (destroyChildren)
153+
{
154+
if (destroyChildren === undefined) { destroyChildren = true; }
155+
156+
if (destroyChildren)
157+
{
158+
for (var i = 0; i < this._list.length; i++)
159+
{
160+
this._list[i].destroy();
161+
}
162+
}
163+
164+
this._list.length = 0;
165+
},
166+
152167
isFull: function ()
153168
{
154169
if (this.maxSize === -1)
@@ -199,7 +214,16 @@ var ObjectPool = new Class({
199214

200215
destroy: function ()
201216
{
217+
this.manager = undefined;
218+
this.state = undefined;
219+
220+
this.displayList = undefined;
221+
this.updateList = undefined;
222+
223+
this.createCallback = undefined;
224+
this.callbackScope = undefined;
202225

226+
this._list.length = 0;
203227
}
204228

205229
});

0 commit comments

Comments
 (0)