Returns a Vector2 containing the x and y position of the given index in a width
x height
sized grid.
For example, in a 6 x 4 grid, index 16 would equal x: 4 y: 2.
If the given index is out of range an empty Vector2 is returned.
name | type | arguments | description |
---|---|---|---|
index | number |
The position within the grid to get the x/y value for. |
|
width | number |
The width of the grid. |
|
height | number |
The height of the grid. |
|
out | Phaser.Math.Vector2 | <optional> |
An optional Vector2 to store the result in. If not given, a new Vector2 instance will be created. |
A Vector2 where the x and y properties contain the given grid index.