Class: Polygon

Phaser. Polygon

Phaser.Polygon

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.

Properties:
Name Type Description
points array.<Phaser.Point> | array.<number>

The array of vertex points

Source:

type

Properties:
Name Type Description
type number

The base object type.

Source:

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
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Wed Oct 22 2014 21:46:04 GMT+0100 (BST) using the DocStrap template.