The Matrix is a 3x3 matrix mostly used for display transforms within the renderer.
It is represented like so:
| a | b | tx |
| c | d | ty |
| 0 | 0 | 1 |
Name | Type | Argument | Default | Description |
---|---|---|---|---|
a | number | <optional> | 1 | Horizontal scaling |
b | number | <optional> | 0 | Horizontal skewing |
c | number | <optional> | 0 | Vertical skewing |
d | number | <optional> | 1 | Vertical scaling |
tx | number | <optional> | 0 | Horizontal translation |
ty | number | <optional> | 0 | Vertical translation |
The const type of this object.
Appends the given Matrix to this Matrix.
Name | Type | Description |
---|---|---|
matrix | Phaser.Matrix | The matrix to append to this one. |
This Matrix object.
Get a new position with the current transformation applied.
Can be used to go from a childs coordinate space to the world coordinate space (e.g. rendering)
Name | Type | Argument | Description |
---|---|---|---|
pos | Phaser.Point | The origin Point. | |
newPos | Phaser.Point | <optional> | The point that the new position is assigned to. This can be same as input point. |
The new point, transformed through this matrix.
Get a new position with the inverse of the current transformation applied.
Can be used to go from the world coordinate space to a childs coordinate space. (e.g. input)
Name | Type | Argument | Description |
---|---|---|---|
pos | Phaser.Point | The origin Point. | |
newPos | Phaser.Point | <optional> | The point that the new position is assigned to. This can be same as input point. |
The new point, inverse transformed through this matrix.
Creates a new Matrix object based on the values of this Matrix.
If you provide the output parameter the values of this Matrix will be copied over to it.
If the output parameter is blank a new Matrix object will be created.
Name | Type | Argument | Description |
---|---|---|---|
output | Phaser.Matrix | <optional> | If provided the values of this Matrix will be copied to it, otherwise a new Matrix object is created. |
A clone of this Matrix.
Copies the properties from the given Matrix into this Matrix.
Name | Type | Description |
---|---|---|
matrix | Phaser.Matrix | The Matrix to copy from. |
This Matrix object.
Copies the properties from this Matrix to the given Matrix.
Name | Type | Description |
---|---|---|
matrix | Phaser.Matrix | The Matrix to copy from. |
The destination Matrix object.
Sets the values of this Matrix to the values in the given array.
The Array elements should be set as follows:
a = array[0]
b = array[1]
c = array[3]
d = array[4]
tx = array[2]
ty = array[5]
Name | Type | Description |
---|---|---|
array | Array | The array to copy from. |
This Matrix object.
Resets this Matrix to an identity (default) matrix.
This Matrix object.
Applies a rotation transformation to this matrix.
Name | Type | Description |
---|---|---|
angle | number | The angle to rotate by, given in radians. |
This Matrix object.
Applies a scale transformation to this matrix.
Name | Type | Description |
---|---|---|
x | number | The amount to scale horizontally. |
y | number | The amount to scale vertically. |
This Matrix object.
Sets the values of this Matrix to the given values.
Name | Type | Description |
---|---|---|
a | number | Horizontal scaling |
b | number | Horizontal skewing |
c | number | Vertical skewing |
d | number | Vertical scaling |
tx | number | Horizontal translation |
ty | number | Vertical translation |
This Matrix object.
Creates a Float32 Array with values populated from this Matrix object.
Name | Type | Argument | Default | Description |
---|---|---|---|---|
transpose | boolean | <optional> | false | Whether the values in the array are transposed or not. |
array | PIXI.Float32Array | <optional> | If provided the values will be set into this array, otherwise a new Float32Array is created. |
The newly created array which contains the matrix.
Translates the matrix on the x and y.
This is the same as Matrix.tx += x.
Name | Type | Description |
---|---|---|
x | number | The x value to translate on. |
y | number | The y value to translate on. |
This Matrix object.
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Matrix.html