Group.removeBetween now properly iterates through the children.

This commit is contained in:
photonstorm 2014-04-09 03:19:36 +01:00
parent 01ccbd97c0
commit b9cb2417b6
2 changed files with 9 additions and 2 deletions

View file

@ -118,6 +118,7 @@ Bug Fixes
* Fixed bug where move up and move down method in groups did not work (thanks @jonthulu, fix #684)
* Fixed bug in Group.next when cursor is at the last child (thanks @jonthulu, fix #688)
* Emitter.minParticleScale and maxParticleScale wasn't resetting the Body size correctly.
* Group.removeBetween now properly iterates through the children.
ToDo

View file

@ -1432,10 +1432,12 @@ Phaser.Group.prototype.removeAll = function () {
*
* @method Phaser.Group#removeBetween
* @param {number} startIndex - The index to start removing children from.
* @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.
* @param {number} [endIndex] - The index to stop removing children at. Must be higher than startIndex. If undefined this method will remove all children between startIndex and the end of the Group.
*/
Phaser.Group.prototype.removeBetween = function (startIndex, endIndex) {
if (typeof endIndex === 'undefined') { endIndex = this.children.length; }
if (this.children.length === 0)
{
return;
@ -1446,7 +1448,9 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex) {
return false;
}
for (var i = startIndex; i < endIndex; i++)
var i = endIndex;
while (i >= startIndex)
{
if (this.children[i].events)
{
@ -1459,6 +1463,8 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex) {
{
this.cursor = null;
}
i--;
}
this.updateZ();