new Vector2([x], [y])
name | type | arguments | Default | description |
---|---|---|---|---|
x | number | Phaser.Types.Math.Vector2Like | <optional> | 0 |
The x component, or an object with |
y | number | <optional> | x |
The y component. |
A static down Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
A static left Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
A static one Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
A static right Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
A static up Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
A static zero Vector2 for use by reference.
This constant is meant for comparison operations and should not be modified directly.
The x component of this Vector.
The y component of this Vector.
Add a given Vector to this Vector. Addition is component-wise.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to add to this Vector. |
This Vector2.
Calculate the angle between this Vector and the positive x-axis, in radians.
The angle between this Vector, and the positive x-axis, given in radians.
Make a clone of this Vector2.
A clone of this Vector2.
Copy the components of a given Vector into this Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to copy the components from. |
This Vector2.
Calculate the cross product of this Vector and the given Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector2 to cross with this Vector2. |
The cross product of this Vector and the given Vector.
Calculate the distance between this Vector and the given Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to calculate the distance to. |
The distance from this Vector to the given Vector.
Calculate the distance between this Vector and the given Vector, squared.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to calculate the distance to. |
The distance from this Vector to the given Vector, squared.
Perform a component-wise division between this Vector and the given Vector.
Divides this Vector by the given Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to divide this Vector by. |
This Vector2.
Calculate the dot product of this Vector and the given Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector2 to dot product with this Vector2. |
The dot product of this Vector and the given Vector.
Check whether this Vector is equal to a given Vector.
Performs a strict equality check against each Vector's components.
name | type | description |
---|---|---|
v | Phaser.Types.Math.Vector2Like |
The vector to compare with this Vector. |
Whether the given Vector is equal to this Vector.
Check whether this Vector is approximately equal to a given Vector.
name | type | arguments | Default | description |
---|---|---|---|---|
v | Phaser.Types.Math.Vector2Like |
The vector to compare with this Vector. |
||
epsilon | number | <optional> | 0.0001 |
The tolerance value. |
Whether both absolute differences of the x and y components are smaller than epsilon
.
Calculate the length (or magnitude) of this Vector.
The length of this Vector.
Calculate the length of this Vector squared.
The length of this Vector, squared.
Linearly interpolate between this Vector and the given Vector.
Interpolates this Vector towards the given Vector.
name | type | arguments | description |
---|---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector2 to interpolate towards. |
|
t | number | <optional> |
The interpolation percentage, between 0 and 1. |
This Vector2.
Limit the length (or magnitude) of this Vector.
name | type | description |
---|---|---|
max | number |
The maximum length. |
This Vector2.
Reflect this Vector across another.
name | type | description |
---|---|---|
axis | Phaser.Math.Vector2 |
A vector to reflect across. |
This Vector2.
Perform a component-wise multiplication between this Vector and the given Vector.
Multiplies this Vector by the given Vector.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to multiply this Vector by. |
This Vector2.
Negate the x
and y
components of this Vector.
This Vector2.
Normalize this Vector.
Makes the vector a unit length vector (magnitude of 1) in the same direction.
This Vector2.
Rotate this Vector to its perpendicular, in the negative direction.
This Vector2.
Rotate this Vector to its perpendicular, in the positive direction.
This Vector2.
Project this Vector onto another.
name | type | description |
---|---|---|
src | Phaser.Math.Vector2 |
The vector to project onto. |
This Vector2.
Reflect this Vector off a line defined by a normal.
name | type | description |
---|---|---|
normal | Phaser.Math.Vector2 |
A vector perpendicular to the line. |
This Vector2.
Make this Vector the zero vector (0, 0).
This Vector2.
Rotate this Vector by an angle amount.
name | type | description |
---|---|---|
delta | number |
The angle to rotate by, in radians. |
This Vector2.
Scale this Vector by the given value.
name | type | description |
---|---|---|
value | number |
The value to scale this Vector by. |
This Vector2.
Set the x
and y
components of the this Vector to the given x
and y
values.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x value to set for this Vector. |
||
y | number | <optional> | x |
The y value to set for this Vector. |
This Vector2.
Set the angle of this Vector.
name | type | description |
---|---|---|
angle | number |
The angle, in radians. |
This Vector2.
Set the component values of this Vector from a given Vector2Like object.
name | type | description |
---|---|---|
obj | Phaser.Types.Math.Vector2Like |
The object containing the component values to set for this Vector. |
This Vector2.
Set the length (or magnitude) of this Vector.
name | type |
---|---|
length | number |
This Vector2.
This method is an alias for Vector2.set
.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x value to set for this Vector. |
||
y | number | <optional> | x |
The y value to set for this Vector. |
This Vector2.
Sets the x
and y
values of this object from a given polar coordinate.
name | type | arguments | Default | description |
---|---|---|---|---|
azimuth | number |
The angular coordinate, in radians. |
||
radius | number | <optional> | 1 |
The radial coordinate (length). |
This Vector2.
Subtract the given Vector from this Vector. Subtraction is component-wise.
name | type | description |
---|---|---|
src | Phaser.Types.Math.Vector2Like |
The Vector to subtract from this Vector. |
This Vector2.
Transform this Vector with the given Matrix.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix3 |
The Matrix3 to transform this Vector2 with. |
This Vector2.
Transform this Vector with the given Matrix.
name | type | description |
---|---|---|
mat | Phaser.Math.Matrix4 |
The Matrix4 to transform this Vector2 with. |
This Vector2.