phaser - v3.90.0
    Preparing search index...

    A representation of a vector in 2D space.

    A two-component vector.

    Index

    Constructors

    • Parameters

      • Optionalx: number | Vector2Like

        The x component, or an object with x and y properties. Default 0.

      • Optionaly: number

        The y component. Default x.

      Returns Math.Vector2

    Properties

    x: number

    The x component of this Vector.

    y: number

    The y component of this Vector.

    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.

    RIGHT: Math.Vector2

    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.

    Methods

    • Calculate the angle between this Vector and the positive x-axis, in radians.

      Returns number

    • Calculate the cross product of this Vector and the given Vector.

      Parameters

      • src: Vector2Like

        The Vector2 to cross with this Vector2.

      Returns number

    • Calculate the distance between this Vector and the given Vector.

      Parameters

      • src: Vector2Like

        The Vector to calculate the distance to.

      Returns number

    • Calculate the distance between this Vector and the given Vector, squared.

      Parameters

      • src: Vector2Like

        The Vector to calculate the distance to.

      Returns number

    • Perform a component-wise division between this Vector and the given Vector.

      Divides this Vector by the given Vector.

      Parameters

      Returns Math.Vector2

    • Calculate the dot product of this Vector and the given Vector.

      Parameters

      • src: Vector2Like

        The Vector2 to dot product with this Vector2.

      Returns number

    • Check whether this Vector is equal to a given Vector.

      Performs a strict equality check against each Vector's components.

      Parameters

      Returns boolean

    • Check whether this Vector is approximately equal to a given Vector.

      Parameters

      • v: Vector2Like

        The vector to compare with this Vector.

      • Optionalepsilon: number

        The tolerance value. Default 0.0001.

      Returns boolean

    • Calculate the length (or magnitude) of this Vector.

      Returns number

    • Calculate the length of this Vector squared.

      Returns number

    • Linearly interpolate between this Vector and the given Vector.

      Interpolates this Vector towards the given Vector.

      Parameters

      • src: Vector2Like

        The Vector2 to interpolate towards.

      • Optionalt: number

        The interpolation percentage, between 0 and 1. Default 0.

      Returns Math.Vector2

    • Limit the length (or magnitude) of this Vector.

      Parameters

      • max: number

        The maximum length.

      Returns Math.Vector2

    • Perform a component-wise multiplication between this Vector and the given Vector.

      Multiplies this Vector by the given Vector.

      Parameters

      • src: Vector2Like

        The Vector to multiply this Vector by.

      Returns Math.Vector2

    • Negate the x and y components of this Vector.

      Returns Math.Vector2

    • Normalize this Vector.

      Makes the vector a unit length vector (magnitude of 1) in the same direction.

      Returns Math.Vector2

    • Rotate this Vector to its perpendicular, in the negative direction.

      Returns Math.Vector2

    • Rotate this Vector to its perpendicular, in the positive direction.

      Returns Math.Vector2

    • Make this Vector the zero vector (0, 0).

      Returns Math.Vector2

    • Rotate this Vector by an angle amount.

      Parameters

      • delta: number

        The angle to rotate by, in radians.

      Returns Math.Vector2

    • Scale this Vector by the given value.

      Parameters

      • value: number

        The value to scale this Vector by.

      Returns Math.Vector2

    • Set the x and y components of the this Vector to the given x and y values.

      Parameters

      • x: number

        The x value to set for this Vector.

      • Optionaly: number

        The y value to set for this Vector. Default x.

      Returns Math.Vector2

    • Set the angle of this Vector.

      Parameters

      • angle: number

        The angle, in radians.

      Returns Math.Vector2

    • Set the component values of this Vector from a given Vector2Like object.

      Parameters

      • obj: Vector2Like

        The object containing the component values to set for this Vector.

      Returns Math.Vector2

    • Set the length (or magnitude) of this Vector.

      Parameters

      • length: number

      Returns Math.Vector2

    • This method is an alias for Vector2.set.

      Parameters

      • x: number

        The x value to set for this Vector.

      • Optionaly: number

        The y value to set for this Vector. Default x.

      Returns Math.Vector2

    • Sets the x and y values of this object from a given polar coordinate.

      Parameters

      • azimuth: number

        The angular coordinate, in radians.

      • Optionalradius: number

        The radial coordinate (length). Default 1.

      Returns Math.Vector2

    • Subtract the given Vector from this Vector. Subtraction is component-wise.

      Parameters

      • src: Vector2Like

        The Vector to subtract from this Vector.

      Returns Math.Vector2

    • Transform this Vector with the given Matrix.

      Parameters

      • mat: Matrix3

        The Matrix3 to transform this Vector2 with.

      Returns Math.Vector2