Graphics.drawPolygon can now accept a Phaser.Polygon or PIXI.Polygon object, as well as a points array (#1712)

This commit is contained in:
photonstorm 2015-04-13 13:00:52 +01:00
parent f155ad452c
commit bb8b0d04fc
2 changed files with 7 additions and 1 deletions

View file

@ -254,6 +254,7 @@ Version 2.3.1 - "Katar" - in dev
* Added missing `resumed` method to Phaser.State class template. * Added missing `resumed` method to Phaser.State class template.
* Color.webToColor and Color.updateColor now updates the `out.color` and `out.color32` properties (thanks @cuixiping #1728) * Color.webToColor and Color.updateColor now updates the `out.color` and `out.color32` properties (thanks @cuixiping #1728)
* 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) * 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)
* Graphics.drawPolygon can now accept a Phaser.Polygon or PIXI.Polygon object, as well as a points array (#1712)
### Bug Fixes ### Bug Fixes

View file

@ -583,11 +583,16 @@ PIXI.Graphics.prototype.drawEllipse = function(x, y, width, height)
* Draws a polygon using the given path. * Draws a polygon using the given path.
* *
* @method drawPolygon * @method drawPolygon
* @param path {Array} The path data used to construct the polygon. If you've got a Phaser.Polygon object then pass `polygon.points` here. * @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.
* @return {Graphics} * @return {Graphics}
*/ */
PIXI.Graphics.prototype.drawPolygon = function(path) PIXI.Graphics.prototype.drawPolygon = function(path)
{ {
if (path instanceof Phaser.Polygon || path instanceof PIXI.Polygon)
{
path = path.points;
}
// prevents an argument assignment deopt // prevents an argument assignment deopt
// see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments // see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
var points = path; var points = path;