Phaser API Documentation

  Version: 

Member of: Phaser.Geom.Polygon

setTo([points])

Description:

Sets this Polygon to the given points.

The points can be set from a variety of formats:

  • A string containing paired values separated by a single space: '40 0 40 20 100 20 100 80 40 80 40 100 0 50'
  • 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], ...]

setTo may also be called without any arguments to remove all points.

Parameters:

name type arguments description
points string | Array.<number> | Array.<Phaser.Types.Math.Vector2Like> <optional>

Points defining the perimeter of this polygon. Please check function description above for the different supported formats.

Returns:
Description:

This Polygon object.

Since: 3.0.0