Class Vector2

Vector 2 represents pairs of X and Y values. Use to represent all bidimensional variables.

Mouse position, acceleration use this object type.

Constructors

Properties

x y

Methods

Constructors

  • Constructor for a new Vector2 object.

    Parameters

    • x: number = 0

      X coordinate.

    • y: number = 0

      Y coordinate.

    Returns Vector2

Properties

x: number

X component of the vector.

y: number

Y component of the vector.

Methods

  • Add the value of another vector to this vector.

    Parameters

    Returns void

  • Copy values from another vector to this one.

    Parameters

    • vec: Vector2

      Vector to copy data from.

    Returns void

  • Distance to another vector.

    Parameters

    • vec: Vector2

      Another vector to calculate distance.

    Returns number

  • Div the value of this vector by a scalar.

    Parameters

    • scalar: number

      Scalar value.

    Returns void

  • Set the value of the vector.

    Parameters

    • x: number

      X coordinate.

    • y: number

      Y coordinate.

    Returns void