Creates a new Polygon.
The points can be set from a variety of formats:
[new Phaser.Point(x1, y1), ...]
[obj1, obj2, ...]
[x1,y1, x2,y2, ...]
setTo(new Phaser.Point(x1, y1), ...)
setTo(obj1, obj2, ...)
setTo(x1,y1, x2,y2, ...)
Name | Type | Description |
---|---|---|
points | Array.<Phaser.Point> | Array.<number> | Phaser.Point | number | The points to set. |
The area of this Polygon.
Is the Polygon closed or not?
Has this Polygon been flattened by a call to Polygon.flatten
?
Sets and modifies the points of this polygon.
See setTo for the different kinds of arrays formats that can be assigned. The array of vertex points.
The base object type.
Creates a copy of the given Polygon.
This is a deep clone, the resulting copy contains new Phaser.Point objects
Name | Type | Argument | Default | Description |
---|---|---|---|---|
output | Phaser.Polygon | <optional> | (new Polygon) | The polygon to update. If not specified a new polygon will be created. |
The cloned (output
) polygon object.
Checks whether the x and y coordinates are contained within this polygon.
Name | Type | Description |
---|---|---|
x | number | The X value of the coordinate to test. |
y | number | The Y value of the coordinate to test. |
True if the coordinates are within this polygon, otherwise false.
Flattens this Polygon so the points are a sequence of numbers.
Any Point objects found are removed and replaced with two numbers.
Also sets the Polygon.flattened property to true
.
This Polygon object
Sets this Polygon to the given points.
The points can be set from a variety of formats:
[new Phaser.Point(x1, y1), ...]
[obj1, obj2, ...]
[x1,y1, x2,y2, ...]
[[x1, y1], [x2, y2], ...]
setTo(new Phaser.Point(x1, y1), ...)
setTo(obj1, obj2, ...)
setTo(x1,y1, x2,y2, ...)
setTo
may also be called without any arguments to remove all points.
Name | Type | Description |
---|---|---|
points | Array.<Phaser.Point> | Array.<number> | Phaser.Point | number | The points to set. |
This Polygon object
Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ]
Name | Type | Argument | Description |
---|---|---|---|
output | array | <optional> | The array to append the points to. If not specified a new array will be created. |
The flattened array.
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Polygon.html