mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Polygon & drawPolygon method
This commit is contained in:
parent
1eca16a948
commit
06e33bc8e4
3 changed files with 27 additions and 0 deletions
|
@ -18,6 +18,7 @@ module.exports = function (grunt) {
|
|||
'src/pixi/core/Matrix.js',
|
||||
'src/pixi/core/Point.js',
|
||||
'src/pixi/core/Rectangle.js',
|
||||
'src/pixi/core/Polygon.js',
|
||||
'src/pixi/display/DisplayObject.js',
|
||||
'src/pixi/display/DisplayObjectContainer.js',
|
||||
'src/pixi/display/Sprite.js',
|
||||
|
@ -82,6 +83,7 @@ module.exports = function (grunt) {
|
|||
'src/geom/Circle.js',
|
||||
'src/geom/Point.js',
|
||||
'src/geom/Rectangle.js',
|
||||
'src/geom/Polygon.js',
|
||||
'src/net/Net.js',
|
||||
'src/tween/TweenManager.js',
|
||||
'src/tween/Tween.js',
|
||||
|
|
|
@ -50,6 +50,18 @@ Phaser.Graphics.prototype.destroy = function() {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled
|
||||
*/
|
||||
Phaser.Graphics.prototype.drawPolygon = function (poly) {
|
||||
|
||||
graphics.moveTo(poly.points[0].x, poly.points[0].y);
|
||||
for (var i = 1; i < poly.points.length; i += 1) {
|
||||
graphics.lineTo(poly.points[i].x, poly.points[i].y);
|
||||
}
|
||||
graphics.lineTo(poly.points[0].x, poly.points[0].y);
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
|
|
13
src/geom/Polygon.js
Normal file
13
src/geom/Polygon.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
Phaser.Polygon = function (points) {
|
||||
|
||||
PIXI.Polygon.call(this, points);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.POLYGON;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Polygon.prototype = Object.create(PIXI.Polygon.prototype);
|
||||
Phaser.Polygon.prototype.constructor = Phaser.Polygon;
|
Loading…
Reference in a new issue