Skip to content

Commit e08e086

Browse files
committed
Phaser.ArrayUtils.rotate is now deprecated. Please use Phaser.ArrayUtils.rotateLeft instead.
1 parent 0036bf7 commit e08e086

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
322322
* 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)
323323
* Phaser now has support for Typings, the TypeScript Definition Manager. See the `typescript/readme.md` file for installation instructions (thanks @monagames #2576)
324324
* Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
325-
* 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.
325+
* Phaser.ArrayUtils.rotateRight 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.
326+
* Phaser.ArrayUtils.rotateLeft is the new name for Phaser.ArrayUtils.rotate. The old method is now deprecated (but still available in this release)
326327

327328
### Updates
328329

@@ -335,6 +336,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
335336
* Phaser.Utils.pad now calls `toString` on the input given, which means you can pass in common data types, such as numbers, and have them padded and returned as strings.
336337
* The canvas created by Phaser.Debug for use when displaying debug data is no longer stored in the CanvasPool, and is instead a stand-alone canvas, free from ever being re-used by another game object.
337338
* BitmapData has a new, optional, fifth argument: `skipPool`. By default BitmapData objects will ask for the first free canvas found in the CanvasPool, but this behavior can now be customized on a per object basis.
339+
* Phaser.ArrayUtils.rotate is now deprecated. Please use Phaser.ArrayUtils.rotateLeft instead.
338340

339341
### Bug Fixes
340342

src/utils/ArrayUtils.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,17 @@ Phaser.ArrayUtils = {
195195
/**
196196
* Moves the element from the end of the array to the start, shifting all items in the process.
197197
* The "rotation" happens to the right.
198-
* See also Phaser.ArrayUtils.rotate.
199198
*
200-
* @method Phaser.ArrayUtils.shift
201-
* @param {any[]} array - The array to shift. The array is modified.
199+
* Before: `[ A, B, C, D, E, F ]`
200+
* After: `[ F, A, B, C, D, E ]`
201+
*
202+
* See also Phaser.ArrayUtils.rotateLeft.
203+
*
204+
* @method Phaser.ArrayUtils.rotateRight
205+
* @param {any[]} array - The array to rotate. The array is modified.
202206
* @return {any} The shifted value.
203207
*/
204-
shift: function (array) {
208+
rotateRight: function (array) {
205209

206210
var s = array.pop();
207211
array.unshift(s);
@@ -213,9 +217,36 @@ Phaser.ArrayUtils = {
213217
/**
214218
* Moves the element from the start of the array to the end, shifting all items in the process.
215219
* The "rotation" happens to the left.
216-
* See also Phaser.ArrayUtils.shift.
220+
*
221+
* Before: `[ A, B, C, D, E, F ]`
222+
* After: `[ B, C, D, E, F, A ]`
223+
*
224+
* See also Phaser.ArrayUtils.rotateRight
225+
*
226+
* @method Phaser.ArrayUtils.rotateLeft
227+
* @param {any[]} array - The array to rotate. The array is modified.
228+
* @return {any} The rotated value.
229+
*/
230+
rotateLeft: function (array) {
231+
232+
var s = array.shift();
233+
array.push(s);
234+
235+
return s;
236+
237+
},
238+
239+
/**
240+
* Moves the element from the start of the array to the end, shifting all items in the process.
241+
* The "rotation" happens to the left.
242+
*
243+
* Before: `[ A, B, C, D, E, F ]`
244+
* After: `[ B, C, D, E, F, A ]`
245+
*
246+
* See also Phaser.ArrayUtils.rotateRight
217247
*
218248
* @method Phaser.ArrayUtils.rotate
249+
* @deprecated Please use Phaser.ArrayUtils.rotate instead.
219250
* @param {any[]} array - The array to rotate. The array is modified.
220251
* @return {any} The rotated value.
221252
*/

0 commit comments

Comments
 (0)