Skip to content

Commit bb8b0d0

Browse files
committed
Graphics.drawPolygon can now accept a Phaser.Polygon or PIXI.Polygon object, as well as a points array (phaserjs#1712)
1 parent f155ad4 commit bb8b0d0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ Version 2.3.1 - "Katar" - in dev
254254
* Added missing `resumed` method to Phaser.State class template.
255255
* Color.webToColor and Color.updateColor now updates the `out.color` and `out.color32` properties (thanks @cuixiping #1728)
256256
* Tilemap.createFromObjects has been updated for Tiled 0.11 and can now look-up object layers based on id, uid or name. It will also now copy over Sprite scaling properties if set (thanks @mandarinx #1738)
257+
* Graphics.drawPolygon can now accept a Phaser.Polygon or PIXI.Polygon object, as well as a points array (#1712)
257258

258259
### Bug Fixes
259260

src/pixi/primitives/Graphics.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,16 @@ PIXI.Graphics.prototype.drawEllipse = function(x, y, width, height)
583583
* Draws a polygon using the given path.
584584
*
585585
* @method drawPolygon
586-
* @param path {Array} The path data used to construct the polygon. If you've got a Phaser.Polygon object then pass `polygon.points` here.
586+
* @param path {Array|Phaser.Polygon} The path data used to construct the polygon. Can either be an array of points or a Phaser.Polygon object.
587587
* @return {Graphics}
588588
*/
589589
PIXI.Graphics.prototype.drawPolygon = function(path)
590590
{
591+
if (path instanceof Phaser.Polygon || path instanceof PIXI.Polygon)
592+
{
593+
path = path.points;
594+
}
595+
591596
// prevents an argument assignment deopt
592597
// see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
593598
var points = path;

0 commit comments

Comments
 (0)