mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
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:
parent
6979103634
commit
089dfbb960
2 changed files with 26 additions and 1 deletions
|
@ -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.
|
||||
* 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.
|
||||
|
||||
* Group.resetCursor will reset the Group cursor back to the start of the group, or to the given index value.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue