phaser - v4.0.0-rc.4
    Preparing search index...

    A representation of a vector in 2D space.

    A two-component vector.

    Hierarchy (View Summary)

    Index

    Constructors

    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 distance between this Vector and the given Vector, squared.

      Parameters

      • src: Vector2Like

        The Vector to calculate the distance to.

      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

    • 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

    • Calculates the vector projection of this Vector2 onto the non-zero vecB. This is the orthogonal projection of this vector onto a straight line parallel to vecB.

      Parameters

      • vecB: Math.Vector2

        The vector to project onto.

      • Optionalout: Math.Vector2

        The Vector2 object to store the position in. If not given, a new Vector2 instance is created.

      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

    • 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 components of this Vector from the given angle and length.

      Parameters

      • angle: number

        The angle from the positive x-axis, in radians.

      • Optionallength: number

        The distance from the origin. Default 1.

      Returns Math.Vector2