numberArrayStep(start, end, step) → {Array}
Create an array of numbers (positive and/or negative) progressing from start
up to but not including end by advancing by step.
If start is less than end a zero-length range is created unless a negative step is specified.
Certain values for start and end (eg. NaN/undefined/null) are currently coerced to 0;
for forward compatibility make sure to pass in actual numbers.
Parameters
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
start | number | The start of the range. | ||
end | number | <optional> | The end of the range. | |
step | number | <optional> | 1 | The value to increment or decrement by. |
Returns
Array -
Returns the new array of numbers.
- Source code: utils/ArrayUtils.js (Line 284)
Example
Phaser.ArrayUtils.numberArrayStep(4); // => [0, 1, 2, 3] Phaser.ArrayUtils.numberArrayStep(1, 5); // => [1, 2, 3, 4] Phaser.ArrayUtils.numberArrayStep(0, 20, 5); // => [0, 5, 10, 15] Phaser.ArrayUtils.numberArrayStep(0, -4, -1); // => [0, -1, -2, -3] Phaser.ArrayUtils.numberArrayStep(1, 4, 0); // => [1, 1, 1] Phaser.ArrayUtils.numberArrayStep(0); // => []
Please login to continue.