new Circle( [x] [, y] [, diameter])
Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
x |
number |
<optional> |
0 | The x coordinate of the center of the circle. |
y |
number |
<optional> |
0 | The y coordinate of the center of the circle. |
diameter |
number |
<optional> |
0 | The diameter of the circle. |
- Source:
- src/geom/Circle.js line 17
Members
-
<readonly> area : number
-
The area of this Circle.
Type:
- number
- Source:
- src/geom/Circle.js line 440
-
bottom : number
-
The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the bottom of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 413
-
diameter : number
-
The largest distance between any two points on the circle. The same as the radius * 2. Gets or sets the diameter of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 285
-
empty : boolean
-
Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. Gets or sets the empty state of the circle.
Type:
- boolean
- Source:
- src/geom/Circle.js line 462
-
left
-
The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
- Source:
- src/geom/Circle.js line 332
-
radius : number
-
The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. Gets or sets the radius of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 309
-
right : number
-
The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. Gets or sets the value of the rightmost point of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 359
-
top : number
-
The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. Gets or sets the top of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 386
-
<readonly> type : number
-
The const type of this object.
Type:
- number
- Source:
- src/geom/Circle.js line 54
-
x : number
-
The x coordinate of the center of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 26
-
y : number
-
The y coordinate of the center of the circle.
Type:
- number
- Source:
- src/geom/Circle.js line 31
Methods
-
<static> circumferencePoint(a, angle [, asDegrees] [, out])
-
Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
Parameters:
Name Type Argument Default Description aPhaser.Circle The first Circle object.
anglenumber The angle in radians (unless asDegrees is true) to return the point from.
asDegreesboolean <optional>
false Is the given angle in radians (false) or degrees (true)?
outPhaser.Point <optional>
An optional Point object to put the result in to. If none specified a new Point object will be created.
- Source:
- src/geom/Circle.js line 534
Returns:
The Point object holding the result.
- Type
- Phaser.Point
-
<static> contains(a, x, y)
-
Return true if the given x/y coordinates are within the Circle object.
Parameters:
Name Type Description aPhaser.Circle The Circle to be checked.
xnumber The X value of the coordinate to test.
ynumber The Y value of the coordinate to test.
- Source:
- src/geom/Circle.js line 485
Returns:
True if the coordinates are within this circle, otherwise false.
- Type
- boolean
-
<static> equals(a, b)
-
Determines whether the two Circle objects match. This method compares the x, y and diameter properties.
Parameters:
Name Type Description aPhaser.Circle The first Circle object.
bPhaser.Circle The second Circle object.
- Source:
- src/geom/Circle.js line 509
Returns:
A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
- Type
- boolean
-
<static> intersects(a, b)
-
Determines whether the two Circle objects intersect. This method checks the radius distances between the two Circle objects to see if they intersect.
Parameters:
Name Type Description aPhaser.Circle The first Circle object.
bPhaser.Circle The second Circle object.
- Source:
- src/geom/Circle.js line 521
Returns:
A value of true if the specified object intersects with this Circle object; otherwise false.
- Type
- boolean
-
<static> intersectsLine(c, l [, returnpoints])
-
Checks if the given Circle and Line objects intersect.
Parameters:
Name Type Argument Description cPhaser.Circle The Circle object to test.
lPhaser.Line The Line object to test.
returnpointsboolean <optional>
optional Array Object, Return an array of intersection points if true, otherwise return boolean.
- Source:
- src/geom/Circle.js line 598
Returns:
True if the two objects intersect, otherwise false.
- Type
- boolean
-
<static> intersectsRectangle(c, r)
-
Checks if the given Circle and Rectangle objects intersect.
Parameters:
Name Type Description cPhaser.Circle The Circle object to test.
rPhaser.Rectangle The Rectangle object to test.
- Source:
- src/geom/Circle.js line 559
Returns:
True if the two objects intersect, otherwise false.
- Type
- boolean
-
circumference()
-
The circumference of the circle.
- Source:
- src/geom/Circle.js line 59
Returns:
The circumference of the circle.
- Type
- number
-
circumferencePoint(angle [, asDegrees] [, out])
-
Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
Parameters:
Name Type Argument Default Description anglenumber The angle in radians (unless asDegrees is true) to return the point from.
asDegreesboolean <optional>
false Is the given angle in radians (false) or degrees (true)?
outPhaser.Point <optional>
An optional Point object to put the result in to. If none specified a new Point object will be created.
- Source:
- src/geom/Circle.js line 195
Returns:
The Point object holding the result.
- Type
- Phaser.Point
-
clone( [output])
-
Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object.
Parameters:
Name Type Argument Description outputPhaser.Circle <optional>
Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
- Source:
- src/geom/Circle.js line 163
Returns:
The cloned Circle object.
- Type
- Phaser.Circle
-
contains(x, y)
-
Return true if the given x/y coordinates are within this Circle object.
Parameters:
Name Type Description xnumber The X value of the coordinate to test.
ynumber The Y value of the coordinate to test.
- Source:
- src/geom/Circle.js line 183
Returns:
True if the coordinates are within this circle, otherwise false.
- Type
- boolean
-
copyFrom(source)
-
Copies the x, y and diameter properties from any given object to this Circle.
Parameters:
Name Type Description sourceany The object to copy from.
- Source:
- src/geom/Circle.js line 123
Returns:
This Circle object.
- Type
- Circle
-
copyTo(dest)
-
Copies the x, y and diameter properties from this Circle to any given object.
Parameters:
Name Type Description destany The object to copy to.
- Source:
- src/geom/Circle.js line 134
Returns:
This dest object.
- Type
- object
-
distance(dest [, round])
-
Returns the distance from the center of the Circle object to the given object (can be Circle, Point or anything with x/y properties)
Parameters:
Name Type Argument Default Description destobject The target object. Must have visible x and y properties that represent the center of the object.
roundboolean <optional>
false Round the distance to the nearest integer.
- Source:
- src/geom/Circle.js line 149
Returns:
The distance between this Point object and the destination Point object.
- Type
- number
-
getBounds()
-
Returns the framing rectangle of the circle as a Phaser.Rectangle object.
- Source:
- src/geom/Circle.js line 94
Returns:
The bounds of the Circle.
- Type
- Phaser.Rectangle
-
offset(dx, dy)
-
Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
Parameters:
Name Type Description dxnumber Moves the x value of the Circle object by this amount.
dynumber Moves the y value of the Circle object by this amount.
- Source:
- src/geom/Circle.js line 245
Returns:
This Circle object.
- Type
- Circle
-
offsetPoint(point)
-
Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.
Parameters:
Name Type Description pointPoint A Point object to use to offset this Circle object (or any valid object with exposed x and y properties).
- Source:
- src/geom/Circle.js line 260
Returns:
This Circle object.
- Type
- Circle
-
random( [out])
-
Returns a uniformly distributed random point from anywhere within this Circle.
Parameters:
Name Type Argument Description outPhaser.Point | object <optional>
A Phaser.Point, or any object with public x/y properties, that the values will be set in. If no object is provided a new Phaser.Point object will be created. In high performance areas avoid this by re-using an existing object.
- Source:
- src/geom/Circle.js line 70
Returns:
An object containing the random point in its
xandyproperties.- Type
- Phaser.Point
-
sample( [steps] [, startAngle] [, endAngle] [, asDegrees] [, out])
-
Creates or positions points on the circle.
The points are equally distributed in the half-closed interval [startAngle, endAngle). The default arc is the entire circle.
If the
outargument is omitted, this method creates and returns an array of points. If an array is passed asout, its items are treated as points and placed in the same way.Parameters:
Name Type Argument Default Description stepstype <optional>
60 The number of points to place.
startAngletype <optional>
0 The starting angle in radians (unless asDegrees is true).
endAngletype <optional>
Phaser.Math.PI2 The end angle in radians (unless asDegrees is true).
asDegreestype <optional>
false Are the given angles in radians (false) or degrees (true)?
outArray.<any> <optional>
An array of points or point-like objects (e.g., sprites). It should start at index 0 and its length should be equal to or greater than
steps.- Source:
- src/geom/Circle.js line 222
Returns:
- The modified
outargument or a new array of points.
- Type
- Array.<any>
-
setTo(x, y, diameter)
-
Sets the members of Circle to the specified values.
Parameters:
Name Type Description xnumber The x coordinate of the center of the circle.
ynumber The y coordinate of the center of the circle.
diameternumber The diameter of the circle.
- Source:
- src/geom/Circle.js line 105
Returns:
This circle object.
- Type
- Circle
-
toString()
-
Returns a string representation of this object.
- Source:
- src/geom/Circle.js line 271
Returns:
a string representation of the instance.
- Type
- string