new Polygon(points)
Creates a new Polygon. You have to provide a list of points.
This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...],
or the arguments passed can be all the points of the polygon e.g. new Phaser.Polygon(new Phaser.Point(), new Phaser.Point(), ...)
, or the
arguments passed can be flat x,y values e.g. new Phaser.Polygon(x,y, x,y, x,y, ...)
where x
and y
are numbers.
Parameters:
Name | Type | Description |
---|---|---|
points |
Array.<Phaser.Point> | Array.<number> | The array of Points. |
- Source:
Members
-
points
-
/* Sets and modifies the points of this polygon.
- Source:
Properties:
Name Type Description points
array.<Phaser.Point> | array.<number> The array of vertex points
-
type
-
- Source:
Properties:
Name Type Description type
number The base object type.
Methods
-
clone(output) → {Phaser.Polygon}
-
Creates a copy of the given Polygon. This is a deep clone, the resulting copy contains new Phaser.Point objects
Parameters:
Name Type Argument Description output
Phaser.Polygon <optional>
Optional Polygon object. If given the values will be set into this object, otherwise a brand new Polygon object will be created and returned.
- Source:
Returns:
The new Polygon object.
- Type
- Phaser.Polygon
-
contains(x, y) → {boolean}
-
Checks whether the x and y coordinates are contained within this polygon.
Parameters:
Name Type Description x
number The X value of the coordinate to test.
y
number The Y value of the coordinate to test.
- Source:
Returns:
True if the coordinates are within this polygon, otherwise false.
- Type
- boolean