Creates a new Polygon.

The points can be set from a variety of formats:

- An array of Point objects:
`[new Phaser.Point(x1, y1), ...]`

- An array of objects with public x/y properties:
`[obj1, obj2, ...]`

- An array of paired numbers that represent point coordinates:
`[x1,y1, x2,y2, ...]`

- As separate Point arguments:
`setTo(new Phaser.Point(x1, y1), ...)`

- As separate objects with public x/y properties arguments:
`setTo(obj1, obj2, ...)`

- As separate arguments representing point coordinates:
`setTo(x1,y1, x2,y2, ...)`

Name | Type | Description |
---|---|---|

`points` | Array.<Phaser.Point> | Array.<number> | Phaser.Point | number | The points to set. |

- Source code: geom/Polygon.js (Line 24)

- Source code: geom/Polygon.js (Line 29)
- Source code: geom/Polygon.js (Line 45)
- Source code: geom/Polygon.js (Line 50)
- This method is
*deprecated*and should not be used. It may be removed in the future. - Array.<Phaser.Point>
- Deprecated:
- Use `setTo`.

- Source code: geom/Polygon.js (Line 294)
- Source code: geom/Polygon.js (Line 55)

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.

- Source code: geom/Polygon.js (Line 109)
- Source code: geom/Polygon.js (Line 134)
- Source code: geom/Polygon.js (Line 91)
- An array of Point objects:
`[new Phaser.Point(x1, y1), ...]`

- An array of objects with public x/y properties:
`[obj1, obj2, ...]`

- An array of paired numbers that represent point coordinates:
`[x1,y1, x2,y2, ...]`

- An array of arrays with two elements representing x/y coordinates:
`[[x1, y1], [x2, y2], ...]`

- As separate Point arguments:
`setTo(new Phaser.Point(x1, y1), ...)`

- As separate objects with public x/y properties arguments:
`setTo(obj1, obj2, ...)`

- As separate arguments representing point coordinates:
`setTo(x1,y1, x2,y2, ...)`

- Source code: geom/Polygon.js (Line 186)
- Source code: geom/Polygon.js (Line 61)

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

boolean -

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:

`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. |

array -

The flattened array.

© 2016 Richard Davey, Photon Storm Ltd.

Licensed under the MIT License.

http://phaser.io/docs/2.6.2/Phaser.Polygon.html