You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phaser.Polygon has been refactored to address some Pixi v2 migration issues (thanks @pnstickne for the original implementation phaserjs#1267)
Polygon.area is now only calculated when the Polygon points list is modified, rather than on every call.
Phaser.Polygon can now accept the points list in a variety of formats: Arrays of Points, numbers, objects with public x/y properties or any combination of, or as a parameter list (thanks @pnstickne for the original implementation phaserjs#1267)
Polygon.contains now correctly calculates the result (thanks @pnstickne@BurnedToastphaserjs#1267)
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,9 @@ Version 2.1.4 - "Bethal" - in development
91
91
* Game.destroy now destroys either the WebGLRenderer or CanvasRenderer, whichever Pixi was using.
92
92
* Particle.Emitter will now automatically set `particle.body.skipQuadTree` to `true` to help with collision speeds within Arcade Physics.
93
93
* Particle.Emitter.explode (or `Emitter.start` with the `explode` parameter set to `true`) will immediately emit the required quantity of particles and not delay until the next frame to do so. This means you can re-use a single emitter across multiple places in your game that require explode-style emissions, just by adjusting the `emitter.x` and `emitter.y` properties before calling explode (thanks Insanehero)
94
+
* Phaser.Polygon has been refactored to address some Pixi v2 migration issues (thanks @pnstickne for the original implementation #1267)
95
+
* Polygon.area is now only calculated when the Polygon points list is modified, rather than on every call.
96
+
* Phaser.Polygon can now accept the points list in a variety of formats: Arrays of Points, numbers, objects with public x/y properties or any combination of, or as a parameter list (thanks @pnstickne for the original implementation #1267)
94
97
95
98
### Bug Fixes
96
99
@@ -100,6 +103,8 @@ Version 2.1.4 - "Bethal" - in development
100
103
* Loader.json was using the wrong context in IE9 with XDomainRequest calls (thanks @pnstickne#1258)
101
104
* Polygon.contains was toggling the return value on each valid hit (thanks @Singularetantum#1265#1266)
102
105
* Text.updateText was incorrectly increasing the size of the texture each time it was called (thanks @spayton#1261)
106
+
* Polygon.contains now correctly calculates the result (thanks @pnstickne@BurnedToast#1267)
107
+
* Setting Key.enabled = false while it is down did not reset the isDown state (thanks @pnstickne#1190#1271)
103
108
104
109
105
110
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md
* Creates a new Polygon. You have to provide a list of points.
10
-
* 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, ...],
11
-
* 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
12
-
* 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.
9
+
* Creates a new Polygon.
10
+
*
11
+
* The points can be set from a variety of formats:
12
+
*
13
+
* - An array of Point objects: `[new Phaser.Point(x1, y1), ...]`
14
+
* - An array of objects with public x/y properties: `[obj1, obj2, ...]`
15
+
* - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]`
16
+
* - As separate Point arguments: `setTo(new Phaser.Point(x1, y1), ...)`
17
+
* - As separate objects with public x/y properties arguments: `setTo(obj1, obj2, ...)`
18
+
* - As separate arguments representing point coordinates: `setTo(x1,y1, x2,y2, ...)`
13
19
*
14
20
* @class Phaser.Polygon
15
21
* @constructor
16
-
* @param {Phaser.Point[]|number[]} points - The array of Points.
22
+
* @param {Phaser.Point[]|number[]|...Phaser.Point|...number} points - The points to set.
17
23
*/
18
-
Phaser.Polygon=function(points){
24
+
Phaser.Polygon=function(){
19
25
20
26
/**
21
-
* @property {number} type - The base object type.
22
-
*/
27
+
* @property {number} type - The base object type.
28
+
*/
23
29
this.type=Phaser.POLYGON;
24
30
25
-
// If points isn't an array, use arguments as the array
26
-
if(!(pointsinstanceofArray))
27
-
{
28
-
points=Array.prototype.slice.call(arguments);
29
-
}
30
-
31
-
// If this is a flat array of numbers, convert it to points
32
-
if(points[0]instanceofPhaser.Point)
33
-
{
34
-
varp=[];
35
-
36
-
for(vari=0,il=points.length;i<il;i++)
37
-
{
38
-
p.push(points[i].x,points[i].y);
39
-
}
40
-
41
-
points=p;
42
-
}
31
+
/**
32
+
* @property {number} area - The area of this Polygon.
33
+
*/
34
+
this.area=0;
43
35
44
36
/**
45
-
* @property {array} points - An array of Points that make up this Polygon.
37
+
* @property {array} _points - An array of Points that make up this Polygon.
38
+
* @private
46
39
*/
47
-
this.points=points;
40
+
this._points=[];
41
+
42
+
if(arguments.length>0)
43
+
{
44
+
this.setTo.apply(this,arguments);
45
+
}
48
46
49
47
/**
50
48
* @property {boolean} closed - Is the Polygon closed or not?
@@ -60,12 +58,12 @@ Phaser.Polygon.prototype = {
60
58
* This is a deep clone, the resulting copy contains new Phaser.Point objects
61
59
*
62
60
* @method Phaser.Polygon#clone
63
-
* @param {Phaser.Polygon} [output] Optional Polygon object. If given the values will be set into this object, otherwise a brand new Polygon object will be created and returned.
64
-
* @return {Phaser.Polygon} The new Polygon object.
61
+
* @param {Phaser.Polygon} [output=(new Polygon)] - The polygon to update. If not specified a new polygon will be created.
62
+
* @return {Phaser.Polygon} The cloned (`output`) polygon object.
0 commit comments