new Vector2()
A 2 dimensional vector. This class uses traditional Vector Math.
Name | Type | Description |
---|---|---|
x | number | The x value of the vector. |
y | number | The y value of the vector. |
- Source
Methods
Add(vector) → {Vector2}
Add a vector to this vector. This returns a new vector, as well as changing the original vector.
Name | Type | Description |
---|---|---|
vector | Vector2 | The vector to add. It can be a Vector2 or a number. |
- Source
- The new vector.
- Type:
- Vector2
Copy() → {Vector2}
Creates a new copy of the vector. Useful for when you want to keep the original vector especially when using the Vector2 mathamatical functions.
- Source
- The new vector.
- Type:
- Vector2
Divide(vector) → {Vector2}
Divides a vector by another vector. This returns a new vector, as well as changing the original vector.
Name | Type | Description |
---|---|---|
vector | Vector2 | The vector to divide. It can be a Vector2 or a number. |
- Source
- The new vector.
- Type:
- Vector2
Magnitude() → {number}
Returns the magnitude of the vector.
- Source
- The magnitude of the vector.
- Type:
- number
Multiply(vector) → {Vector2}
Multiply a vector by another vector. This returns a new vector, as well as changing the original vector.
Name | Type | Description |
---|---|---|
vector | Vector2 | The vector to multiply. It can be a Vector2 or a number. |
- Source
- The new vector.
- Type:
- Vector2
Negetive() → {Vector2}
Negates the vector. This returns a new vector, as well as changing the original vector. Rotates the vector 180 degrees.
- Source
- The new vector.
- Type:
- Vector2
Normalize() → {Vector2}
Normalizes the vector. This returns a new vector, as well as changing the original vector.
- Source
- The new vector.
- Type:
- Vector2
Subtract(vector) → {Vector2}
Subtracts a vector from this vector. This returns a new vector, as well as changing the original vector.
Name | Type | Description |
---|---|---|
vector | Vector2 | The vector to subtract. It can be a Vector2 or a number. |
- Source
- The new vector.
- Type:
- Vector2
(static) IsSafe() → {boolean}
Checks if the values of the Vector are Safe Numbers.
- Source
- True if the values are safe numbers.
- Type:
- boolean
(static) One() → {Vector2}
Returns a new vector with elements as One.
- Source
- The new vector.
- Type:
- Vector2
(static) Zero() → {Vector2}
Returns a new vector with elements as Zero.
- Source
- The new vector.
- Type:
- Vector2