Vector2

new Vector2()

A 2 dimensional vector. This class uses traditional Vector Math.

Properties
NameTypeDescription
xnumber

The x value of the vector.

ynumber

The y value of the vector.

Methods

Add(vector) → {Vector2}

Add a vector to this vector. This returns a new vector, as well as changing the original vector.

Parameters:
NameTypeDescription
vectorVector2

The vector to add. It can be a Vector2 or a number.

Returns:
  • 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.

Returns:
  • 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.

Parameters:
NameTypeDescription
vectorVector2

The vector to divide. It can be a Vector2 or a number.

Returns:
  • The new vector.
Type: 
Vector2

Magnitude() → {number}

Returns the magnitude of the vector.

Returns:
  • 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.

Parameters:
NameTypeDescription
vectorVector2

The vector to multiply. It can be a Vector2 or a number.

Returns:
  • 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.

Returns:
  • The new vector.
Type: 
Vector2

Normalize() → {Vector2}

Normalizes the vector. This returns a new vector, as well as changing the original vector.

Returns:
  • 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.

Parameters:
NameTypeDescription
vectorVector2

The vector to subtract. It can be a Vector2 or a number.

Returns:
  • The new vector.
Type: 
Vector2

(static) IsSafe() → {boolean}

Checks if the values of the Vector are Safe Numbers.

Returns:
  • True if the values are safe numbers.
Type: 
boolean

(static) One() → {Vector2}

Returns a new vector with elements as One.

Returns:
  • The new vector.
Type: 
Vector2

(static) Zero() → {Vector2}

Returns a new vector with elements as Zero.

Returns:
  • The new vector.
Type: 
Vector2