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

    A Circle object.

    This is a geometry object, containing numerical values and related methods to inspect and modify them. It is not a Game Object, in that you cannot add it to the display list, and it has no texture. To render a Circle you should look at the capabilities of the Graphics class.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • Optionalx: number

        The x position of the center of the circle. Default 0.

      • Optionaly: number

        The y position of the center of the circle. Default 0.

      • Optionalradius: number

        The radius of the circle. Default 0.

      Returns Circle

    Properties

    bottom: number

    The bottom position of the Circle.

    diameter: number

    The diameter of the Circle.

    left: number

    The left position of the Circle.

    radius: number

    The radius of the Circle.

    right: number

    The right position of the Circle.

    top: number

    The top position of the Circle.

    type: number

    The geometry constant type of this object: GEOM_CONST.CIRCLE. Used for fast type comparisons.

    x: number

    The x position of the center of the circle.

    y: number

    The y position of the center of the circle.

    Methods

    • Check to see if the Circle contains the given x / y coordinates.

      Parameters

      • x: number

        The x coordinate to check within the circle.

      • y: number

        The y coordinate to check within the circle.

      Returns boolean

    • Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

      Type Parameters

      Parameters

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.

      • Optionalout: O

        A Vector2 to store the return values in. If not given a Vector2 object will be created.

      Returns O

    • Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, based on the given quantity or stepRate values.

      Type Parameters

      Parameters

      • quantity: number

        The amount of points to return. If a falsey value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.

      • Optionaloutput: O

        An array to insert the Vector2s in to. If not provided a new array will be created.

      Returns O

    • Checks to see if the Circle is empty: has a radius of zero.

      Returns boolean

    • Sets this Circle to be empty with a radius of zero. Does not change its position.

      Returns this

    • Sets the position of this Circle.

      Parameters

      • Optionalx: number

        The x position of the center of the circle. Default 0.

      • Optionaly: number

        The y position of the center of the circle. Default 0.

      Returns this

    • Sets the x, y and radius of this circle.

      Parameters

      • Optionalx: number

        The x position of the center of the circle. Default 0.

      • Optionaly: number

        The y position of the center of the circle. Default 0.

      • Optionalradius: number

        The radius of the circle. Default 0.

      Returns this

    • Returns the circumference of the given Circle.

      Parameters

      • circle: Circle

        The Circle to get the circumference of.

      Returns number

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle based on the given angle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the circumference point on.

      • angle: number

        The angle from the center of the Circle to the circumference to return the point from. Given in radians.

      • Optionalout: O

        A Vector2 to store the results in. If not given a Point will be created.

      Returns O

    • Creates a new Circle instance based on the values contained in the given source.

      Parameters

      • source: object | Circle

        The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties.

      Returns Circle

    • Check to see if the Circle contains the given x / y coordinates.

      Parameters

      • circle: Circle

        The Circle to check.

      • x: number

        The x coordinate to check within the circle.

      • y: number

        The y coordinate to check within the circle.

      Returns boolean

    • Check to see if the Circle contains the given x and y coordinates as stored in the Vector2.

      Parameters

      • circle: Circle

        The Circle to check.

      • vec: Math.Vector2

        The Vector2 object to check if its coordinates are within the Circle or not.

      Returns boolean

    • Check to see if the Circle contains all four points of the given Rectangle object.

      Parameters

      • circle: Circle

        The Circle to check.

      • rect: object | Geom.Rectangle

        The Rectangle object to check if it's within the Circle or not.

      Returns boolean

    • Copies the x, y and radius properties from the source Circle into the given dest Circle, then returns the dest Circle.

      Type Parameters

      Parameters

      • source: Circle

        The source Circle to copy the values from.

      • dest: O

        The destination Circle to copy the values to.

      Returns O

    • Compares the x, y and radius properties of the two given Circles. Returns true if they all match, otherwise returns false.

      Parameters

      • circle: Circle

        The first Circle to compare.

      • toCompare: Circle

        The second Circle to compare.

      Returns boolean

    • Returns the bounds of the Circle object.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the bounds from.

      • Optionalout: O

        A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created.

      Returns O

    • Returns a Vector2 object containing the coordinates of a point on the circumference of the Circle based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point at 180 degrees around the circle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get the circumference point on.

      • position: number

        A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle.

      • Optionalout: O

        A Vector2 instance to store the return values in. If not given a new Vector2 object will be created.

      Returns O

    • Returns an array of Vector2 objects containing the coordinates of the points around the circumference of the Circle, based on the given quantity or stepRate values.

      Parameters

      • circle: Circle

        The Circle to get the points from.

      • quantity: number

        The amount of points to return. If a falsey value the quantity will be derived from the stepRate instead.

      • OptionalstepRate: number

        Sets the quantity by getting the circumference of the circle and dividing it by the stepRate.

      • Optionaloutput: any[]

        An array to insert the points in to. If not provided a new array will be created.

      Returns Math.Vector2[]

    • Offsets the Circle by the values given.

      Type Parameters

      Parameters

      • circle: O

        The Circle to be offset (translated.)

      • x: number

        The amount to horizontally offset the Circle by.

      • y: number

        The amount to vertically offset the Circle by.

      Returns O

    • Offsets the Circle by the values given in the x and y properties of the Vector2 object.

      Type Parameters

      Parameters

      • circle: O

        The Circle to be offset (translated.)

      • vec: Math.Vector2

        The Vector2 object containing the values to offset the Circle by.

      Returns O

    • Returns a uniformly distributed random point from anywhere within the given Circle.

      Type Parameters

      Parameters

      • circle: Circle

        The Circle to get a random point from.

      • Optionalout: O

        A Vector2 object to set the random x and y values in.

      Returns O