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.
new Circle([x], [y], [radius])
name | type | arguments | description |
---|---|---|---|
x | number | <optional> |
The x position of the center of the circle. |
y | number | <optional> |
The y position of the center of the circle. |
radius | number | <optional> |
The radius of the circle. |
The bottom position of the Circle.
The diameter of the Circle.
The left position of the Circle.
The radius of the Circle.
The right position of the Circle.
The top position of the Circle.
The geometry constant type of this object: GEOM_CONST.CIRCLE
.
Used for fast type comparisons.
The x position of the center of the circle.
The y position of the center of the circle.
Check to see if the Circle contains the given x / y coordinates.
name | type | description |
---|---|---|
x | number |
The x coordinate to check within the circle. |
y | number |
The y coordinate to check within the circle. |
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.
name | type | arguments | description |
---|---|---|---|
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. |
|
out | object | Phaser.Geom.Point | <optional> |
An object to store the return values in. If not given a Point object will be created. |
A Point, or point-like object, 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.
name | type | arguments | description |
---|---|---|---|
quantity | number |
The amount of points to return. If a falsey value the quantity will be derived from the |
|
stepRate | number | <optional> |
Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. |
output | array | Array.<Phaser.Geom.Point> | <optional> |
An array to insert the points in to. If not provided a new array will be created. |
An array of Point objects pertaining to the points around the circumference of the circle.
Returns a uniformly distributed random point from anywhere within the Circle.
name | type | arguments | description |
---|---|---|---|
point | object | Phaser.Geom.Point | <optional> |
A Point or point-like object to set the random |
A Point 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.
True if the Circle is empty, otherwise false.
Sets this Circle to be empty with a radius of zero. Does not change its position.
This Circle object.
Sets the position of this Circle.
name | type | arguments | description |
---|---|---|---|
x | number | <optional> |
The x position of the center of the circle. |
y | number | <optional> |
The y position of the center of the circle. |
This Circle object.
Sets the x, y and radius of this circle.
name | type | arguments | description |
---|---|---|---|
x | number | <optional> |
The x position of the center of the circle. |
y | number | <optional> |
The y position of the center of the circle. |
radius | number | <optional> |
The radius of the circle. |
This Circle object.
Calculates the area of the circle.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The Circle to get the area of. |
The area of the Circle.
Returns the circumference of the given Circle.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The Circle to get the circumference of. |
The circumference of the Circle.
Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
name | type | arguments | description |
---|---|---|---|
circle | Phaser.Geom.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. |
|
out | object | Phaser.Geom.Point | <optional> |
A Point, or point-like object, to store the results in. If not given a Point will be created. |
A Point 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.
name | type | description |
---|---|---|
source | object | Phaser.Geom.Circle |
The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. |
A clone of the source Circle.
Check to see if the Circle contains the given x / y coordinates.
name | type | description |
---|---|---|
circle | Phaser.Geom.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. |
True if the coordinates are within the circle, otherwise false.
Check to see if the Circle contains the given Point object.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The Circle to check. |
point | object | Phaser.Geom.Point |
The Point object to check if it's within the Circle or not. |
True if the Point coordinates are within the circle, otherwise false.
Check to see if the Circle contains all four points of the given Rectangle object.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The Circle to check. |
rect | object | Phaser.Geom.Rectangle |
The Rectangle object to check if it's within the Circle or not. |
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.
name | type | description |
---|---|---|
source | Phaser.Geom.Circle |
The source Circle to copy the values from. |
dest | Phaser.Geom.Circle |
The destination Circle to copy the values to. |
The destination Circle.
Compares the x
, y
and radius
properties of the two given Circles.
Returns true
if they all match, otherwise returns false
.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The first Circle to compare. |
toCompare | Phaser.Geom.Circle |
The second Circle to compare. |
true
if the two Circles equal each other, otherwise false
.
Returns the bounds of the Circle object.
name | type | arguments | description |
---|---|---|---|
circle | Phaser.Geom.Circle |
The Circle to get the bounds from. |
|
out | object | Phaser.Geom.Rectangle | <optional> |
A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. |
The Rectangle object containing the Circles bounds.
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.
name | type | arguments | description |
---|---|---|---|
circle | Phaser.Geom.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. |
|
out | object | Phaser.Geom.Point | <optional> |
An object to store the return values in. If not given a Point object will be created. |
A Point, or point-like object, 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.
name | type | arguments | description |
---|---|---|---|
circle | Phaser.Geom.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 | number | <optional> |
Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. |
output | array | <optional> |
An array to insert the points in to. If not provided a new array will be created. |
An array of Point objects pertaining to the points around the circumference of the circle.
Offsets the Circle by the values given.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
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. |
The Circle that was offset.
Offsets the Circle by the values given in the x
and y
properties of the Point object.
name | type | description |
---|---|---|
circle | Phaser.Geom.Circle |
The Circle to be offset (translated.) |
point | object | Phaser.Geom.Point |
The Point object containing the values to offset the Circle by. |
The Circle that was offset.
Returns a uniformly distributed random point from anywhere within the given Circle.
name | type | arguments | description |
---|---|---|---|
circle | Phaser.Geom.Circle |
The Circle to get a random point from. |
|
out | object | Phaser.Geom.Point | <optional> |
A Point or point-like object to set the random |
A Point object with the random values set in the x
and y
properties.