# Class: Polygon

## Phaser. Polygon

The polygon represents a list of orderded points in space

#### 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:
    - geom/Polygon.js, line 19

### Members

#### points

  /* Sets and modifies the points of this polygon.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `points` | array.<Phaser.Point> | array.<number> | The array of vertex points

  Source:
    - geom/Polygon.js, line 110

#### type

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `type` | number | The base object type.

  Source:
    - geom/Polygon.js, line 24

### Methods

#### clone() → {Phaser.Polygon}

  Creates a clone of this polygon.

  Source:
    - geom/Polygon.js, line 55

  ##### Returns:

  A copy of the polygon.

  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:
    - geom/Polygon.js, line 74

  ##### Returns:

  True if the coordinates are within this polygon, otherwise false.

  Type
    boolean