Navigation
These archived docs are for Phaser 2.2.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

PIXI. Polygon

new Polygon(points)

Parameters
Name Type Description
points Array.<Point> | Array.<Number> | PIXI.Point | Number

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 PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...), or the arguments passed can be flat x,y values e.g. new PIXI.Polygon(x,y, x,y, x,y, ...) where x and y are Numbers.

Source code: pixi/geom/Polygon.js, line 5

Public Properties

points : Array.<Point> | Array.<Number>

An array of the points of this polygon

Type
  • Array.<Point> | Array.<Number>
Source code: pixi/geom/Polygon.js, line 33

type : number

The type of the object, should be one of the Graphics type consts, PIXI.Graphics.POLY in this case

Default Value
  • 0
Source code: pixi/geom/Polygon.js, line 41

Public Methods

clone() → {PIXI.Polygon}

Creates a clone of this polygon

Returns

a copy of the polygon

Source code: pixi/geom/Polygon.js, line 49

contains(x, y) → {Boolean}

Checks whether the x and y coordinates passed to this function are contained within this polygon

Parameters
Name Type Description
x Number

The X coordinate of the point to test

y Number

The Y coordinate of the point to test

Returns
Boolean -

Whether the x/y coordinates are within this polygon

Source code: pixi/geom/Polygon.js, line 61