mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Phaser.ArrayUtils.shift is the opposite of ArrayUtils.rotate. It takes an array, removes the element from the end of the array, and inserts it at the start, shifting everything else 1 space in the process.
This commit is contained in:
parent
1f570b49e8
commit
fdcbb9229b
3 changed files with 23 additions and 2 deletions
|
@ -322,6 +322,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
* The Loader has a new property `headers`. This is an object checked by XHR Requests, used to set the Request Header of certain file types. JSON and XML are pre-configured, but you can add to, or modify this property as required (thanks @stoneman1 #2585 #2485)
|
||||
* Phaser now has support for Typings, the TypeScript Definition Manager. See the `typescript/readme.md` file for installation instructions (thanks @monagames #2576)
|
||||
* Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
|
||||
* Phaser.ArrayUtils.shift is the opposite of ArrayUtils.rotate. It takes an array, removes the element from the end of the array, and inserts it at the start, shifting everything else 1 space in the process.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -192,13 +192,32 @@ Phaser.ArrayUtils = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves the element from the end of the array to the start, shifting all items in the process.
|
||||
* The "rotation" happens to the right.
|
||||
* See also Phaser.ArrayUtils.rotate.
|
||||
*
|
||||
* @method Phaser.ArrayUtils.shift
|
||||
* @param {any[]} array - The array to shift. The array is modified.
|
||||
* @return {any} The shifted value.
|
||||
*/
|
||||
shift: function (array) {
|
||||
|
||||
var s = array.pop();
|
||||
array.unshift(s);
|
||||
|
||||
return s;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Moves the element from the start of the array to the end, shifting all items in the process.
|
||||
* The "rotation" happens to the left.
|
||||
* See also Phaser.ArrayUtils.shift.
|
||||
*
|
||||
* @method Phaser.ArrayUtils.rotate
|
||||
* @param {any[]} array - The array to shift/rotate. The array is modified.
|
||||
* @return {any} The shifted value.
|
||||
* @param {any[]} array - The array to rotate. The array is modified.
|
||||
* @return {any} The rotated value.
|
||||
*/
|
||||
rotate: function (array) {
|
||||
|
||||
|
|
1
typescript/phaser.d.ts
vendored
1
typescript/phaser.d.ts
vendored
|
@ -224,6 +224,7 @@ declare module Phaser {
|
|||
static rotateMatrix(matrix: any, direction: number | string): any;
|
||||
static findClosest(value: number, arr: number[]): number;
|
||||
static rotate(array: any[]): any;
|
||||
static shift(array: any[]): any;
|
||||
static numberArray(start: number, end: number): number[];
|
||||
static numberArrayStep(start: number, end?: number, step?: number): number[];
|
||||
|
||||
|
|
Loading…
Reference in a new issue