Group.resetCursor will reset the Group cursor back to the start of the group, or to the given index value.

This commit is contained in:
photonstorm 2014-04-16 21:39:04 +01:00
parent 6979103634
commit 089dfbb960
2 changed files with 26 additions and 1 deletions

View file

@ -75,7 +75,7 @@ Version 2.0.4 - "Mos Shirare" - in development
* Keyboard.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners. * Keyboard.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
* Key.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners. * Key.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
* InputManager.resetLocked - If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored. * InputManager.resetLocked - If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored.
* Group.resetCursor will reset the Group cursor back to the start of the group, or to the given index value.
### Bug Fixes ### Bug Fixes

View file

@ -353,6 +353,31 @@ Phaser.Group.prototype.updateZ = function () {
}; };
/**
* Sets the Group cursor to the first object in the Group. If the optional index parameter is given it sets the cursor to the object at that index instead.
*
* @method Phaser.Group#resetCursor
* @param {number} [index=0] - Set the cursor to point to a specific index.
* @return {*} The child the cursor now points to.
*/
Phaser.Group.prototype.resetCursor = function (index) {
if (typeof index === 'undefined') { index = 0; }
if (index > this.children.length - 1)
{
index = 0;
}
if (this.cursor)
{
this._cache[8] = index;
this.cursor = this.children[this._cache[8]];
return this.cursor;
}
};
/** /**
* Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object. * Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
* *