2016-12-07 13:34:21 +00:00
|
|
|
/**
|
2018-01-26 14:23:00 +00:00
|
|
|
* Moves the element at the start of the array to the end, shifting all items in the process.
|
|
|
|
* The "rotation" happens to the left.
|
2017-10-12 12:57:55 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Utils.Array.RotateLeft
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {array} array - The array to shift to the left. This array is modified in place.
|
|
|
|
* @param {integer} [total=1] - The number of times to shift the array.
|
|
|
|
*
|
|
|
|
* @return {any} The most recently shifted element.
|
|
|
|
*/
|
2016-12-07 13:34:21 +00:00
|
|
|
var RotateLeft = function (array, total)
|
|
|
|
{
|
|
|
|
if (total === undefined) { total = 1; }
|
|
|
|
|
|
|
|
var element = null;
|
|
|
|
|
|
|
|
for (var i = 0; i < total; i++)
|
|
|
|
{
|
|
|
|
element = array.shift();
|
|
|
|
array.push(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = RotateLeft;
|