PokéRogue
    Preparing search index...

    A Circle geometry object defined by a center position and radius.

    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.

    Circle objects are commonly used for hit-testing, overlap checks, masking, and defining circular regions of interest within a Scene. They can be used directly with Phaser's geometry intersection methods, such as Phaser.Geom.Intersects.CircleToCircle or Phaser.Geom.Intersects.CircleToRectangle, making them useful for simple spatial queries without requiring a physics body.

    Hierarchy (View Summary)

    Index
    • 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

    bottom: number

    The bottommost point of the Circle, equal to y + radius. Setting this value adjusts the y position of the circle's center while keeping the radius unchanged.

    diameter: number

    The diameter of the Circle, which is twice the radius. Setting this value also updates the radius accordingly.

    left: number

    The leftmost point of the Circle, equal to x - radius. Setting this value adjusts the x position of the circle's center while keeping the radius unchanged.

    radius: number

    The radius of the Circle. Setting this value also updates the diameter accordingly.

    right: number

    The rightmost point of the Circle, equal to x + radius. Setting this value adjusts the x position of the circle's center while keeping the radius unchanged.

    top: number

    The topmost point of the Circle, equal to y - radius. Setting this value adjusts the y position of the circle's center while keeping the radius unchanged.

    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.

    • 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

      True if the coordinates are within the circle, otherwise false.

    • 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

      A Vector2 containing the coordinates of the point around the circle.

    • 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 falsy 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

      An array of Vector2 objects pertaining to the points around the circumference of the circle.

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

      Type Parameters

      Parameters

      • Optionalvec: Vector2

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

      Returns O

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

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

      Returns boolean

      True if the Circle is empty, otherwise false.

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

      Returns this

      This Circle object.

    • Sets the position of this Circle. If the y argument is omitted, both the x and y positions will be set to the value of x.

      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

      This Circle object.

    • 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

      This Circle object.

    • Calculates the area of the circle.

      Parameters

      • circle: Circle

        The Circle to get the area of.

      Returns number

      The area of the Circle.

    • Returns the circumference of the given Circle.

      Parameters

      • circle: Circle

        The Circle to get the circumference of.

      Returns number

      The circumference of the Circle.

    • 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 Vector2 will be created.

      Returns O

      A Vector2 object where the x and y properties are the point on the circumference.

    • 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

      A clone of the source 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

      True if the coordinates are within the circle, otherwise false.

    • 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: Vector2

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

      Returns boolean

      True if the Vector2 coordinates are within the circle, otherwise false.

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

      Parameters

      • circle: Circle

        The Circle to check.

      • rect: object | Rectangle

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

      Returns boolean

      True if all of the Rectangle coordinates are within the circle, otherwise false.

    • 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

      The destination Circle.

    • 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

      true if the two Circles equal each other, otherwise false.

    • 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

      The Rectangle object containing the Circle's bounds.

    • 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

      A Vector2 containing the coordinates of the point around the circle.

    • 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 falsy 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.

      • Optionalout: any[]

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

      Returns Vector2[]

      An array of Vector2 objects pertaining to the points around the circumference of the circle.

    • 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

      The Circle that was offset.

    • 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: Vector2

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

      Returns O

      The Circle that was offset.

    • 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

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