Skip to content

Commit 35fd29a

Browse files
committed
Removed Pixi globals, and moved constructors above the prototype.
1 parent 1262ba7 commit 35fd29a

12 files changed

Lines changed: 31 additions & 46 deletions

File tree

src/gameobjects/Rope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ Phaser.Rope.prototype.getBounds = function (matrix) {
754754

755755
if (minX === -Infinity || maxY === Infinity)
756756
{
757-
return PIXI.EmptyRectangle;
757+
return Phaser.EmptyRectangle;
758758
}
759759

760760
var bounds = this._bounds;

src/geom/Circle.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Phaser.Circle = function (x, y, diameter) {
5555

5656
};
5757

58+
Phaser.Circle.prototype.constructor = Phaser.Circle;
59+
5860
Phaser.Circle.prototype = {
5961

6062
/**
@@ -253,8 +255,6 @@ Phaser.Circle.prototype = {
253255

254256
};
255257

256-
Phaser.Circle.prototype.constructor = Phaser.Circle;
257-
258258
/**
259259
* The largest distance between any two points on the circle. The same as the radius * 2.
260260
*
@@ -572,6 +572,3 @@ Phaser.Circle.intersectsRectangle = function (c, r) {
572572
return xCornerDistSq + yCornerDistSq <= maxCornerDistSq;
573573

574574
};
575-
576-
// Because PIXI uses its own Circle, we'll replace it with ours to avoid duplicating code or confusion.
577-
PIXI.Circle = Phaser.Circle;

src/geom/Ellipse.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Phaser.Ellipse = function (x, y, width, height) {
5050

5151
};
5252

53+
Phaser.Ellipse.prototype.constructor = Phaser.Ellipse;
54+
5355
Phaser.Ellipse.prototype = {
5456

5557
/**
@@ -185,8 +187,6 @@ Phaser.Ellipse.prototype = {
185187

186188
};
187189

188-
Phaser.Ellipse.prototype.constructor = Phaser.Ellipse;
189-
190190
/**
191191
* The left coordinate of the Ellipse. The same as the X coordinate.
192192
* @name Phaser.Ellipse#left
@@ -321,6 +321,3 @@ Phaser.Ellipse.contains = function (a, x, y) {
321321
return (normx + normy < 0.25);
322322

323323
};
324-
325-
// Because PIXI uses its own Ellipse, we'll replace it with ours to avoid duplicating code or confusion.
326-
PIXI.Ellipse = Phaser.Ellipse;

src/geom/Line.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Phaser.Line = function (x1, y1, x2, y2) {
3939

4040
};
4141

42+
Phaser.Line.prototype.constructor = Phaser.Line;
43+
4244
Phaser.Line.prototype = {
4345

4446
/**

src/geom/Matrix.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Phaser.Matrix = function (a, b, c, d, tx, ty) {
7676

7777
};
7878

79+
Phaser.Matrix.prototype.constructor = Phaser.Matrix;
80+
7981
Phaser.Matrix.prototype = {
8082

8183
/**

src/geom/Point.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Phaser.Point = function (x, y) {
3838

3939
};
4040

41+
Phaser.Point.prototype.constructor = Phaser.Point;
42+
4143
Phaser.Point.prototype = {
4244

4345
/**
@@ -486,8 +488,6 @@ Phaser.Point.prototype = {
486488

487489
};
488490

489-
Phaser.Point.prototype.constructor = Phaser.Point;
490-
491491
/**
492492
* Adds the coordinates of two points together to create a new point.
493493
*
@@ -901,6 +901,3 @@ Phaser.Point.parse = function(obj, xProp, yProp) {
901901
return point;
902902

903903
};
904-
905-
// Because PIXI uses its own Point, we'll replace it with ours to avoid duplicating code or confusion.
906-
PIXI.Point = Phaser.Point;

src/geom/Polygon.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Phaser.Polygon = function () {
5656

5757
};
5858

59+
Phaser.Polygon.prototype.constructor = Phaser.Polygon;
60+
5961
Phaser.Polygon.prototype = {
6062

6163
/**
@@ -222,16 +224,16 @@ Phaser.Polygon.prototype = {
222224
{
223225
if (typeof points[i] === 'number')
224226
{
225-
var p = new PIXI.Point(points[i], points[i + 1]);
227+
var p = new Phaser.Point(points[i], points[i + 1]);
226228
i++;
227229
}
228230
else if (Array.isArray(points[i]))
229231
{
230-
var p = new PIXI.Point(points[i][0], points[i][1]);
232+
var p = new Phaser.Point(points[i][0], points[i][1]);
231233
}
232234
else
233235
{
234-
var p = new PIXI.Point(points[i].x, points[i].y);
236+
var p = new Phaser.Point(points[i].x, points[i].y);
235237
}
236238

237239
this._points.push(p);
@@ -289,8 +291,6 @@ Phaser.Polygon.prototype = {
289291

290292
};
291293

292-
Phaser.Polygon.prototype.constructor = Phaser.Polygon;
293-
294294
/**
295295
* Sets and modifies the points of this polygon.
296296
*
@@ -321,6 +321,3 @@ Object.defineProperty(Phaser.Polygon.prototype, 'points', {
321321
}
322322

323323
});
324-
325-
// Because PIXI uses its own type, we'll replace it with ours to avoid duplicating code or confusion.
326-
PIXI.Polygon = Phaser.Polygon;

src/geom/Rectangle.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Phaser.Rectangle = function (x, y, width, height) {
5050

5151
};
5252

53+
Phaser.Rectangle.prototype.constructor = Phaser.Rectangle;
54+
5355
Phaser.Rectangle.prototype = {
5456

5557
/**
@@ -756,8 +758,6 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
756758

757759
});
758760

759-
Phaser.Rectangle.prototype.constructor = Phaser.Rectangle;
760-
761761
/**
762762
* Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
763763
* @method Phaser.Rectangle.inflate
@@ -1053,7 +1053,3 @@ Phaser.Rectangle.aabb = function(points, out) {
10531053

10541054
return out;
10551055
};
1056-
1057-
// Because PIXI uses its own Rectangle, we'll replace it with ours to avoid duplicating code or confusion.
1058-
PIXI.Rectangle = Phaser.Rectangle;
1059-
PIXI.EmptyRectangle = new Phaser.Rectangle(0, 0, 0, 0);

src/geom/RoundedRectangle.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Phaser.RoundedRectangle = function(x, y, width, height, radius)
5757
this.type = Phaser.ROUNDEDRECTANGLE;
5858
};
5959

60+
Phaser.RoundedRectangle.prototype.constructor = Phaser.RoundedRectangle;
61+
6062
Phaser.RoundedRectangle.prototype = {
6163

6264
/**
@@ -104,8 +106,3 @@ Phaser.RoundedRectangle.prototype = {
104106
}
105107

106108
};
107-
108-
Phaser.RoundedRectangle.prototype.constructor = Phaser.RoundedRectangle;
109-
110-
// Because PIXI uses its own type, we'll replace it with ours to avoid duplicating code or confusion.
111-
PIXI.RoundedRectangle = Phaser.RoundedRectangle;

src/pixi/display/DisplayObject.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PIXI.DisplayObject = function () {
2626
* @property {PIXI.Point} position
2727
* @default
2828
*/
29-
this.position = new PIXI.Point(0, 0);
29+
this.position = new Phaser.Point(0, 0);
3030

3131
/**
3232
* The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject
@@ -38,15 +38,15 @@ PIXI.DisplayObject = function () {
3838
* @property {PIXI.Point} scale
3939
* @default
4040
*/
41-
this.scale = new PIXI.Point(1, 1);
41+
this.scale = new Phaser.Point(1, 1);
4242

4343
/**
4444
* The pivot point of this DisplayObject that it rotates around. The values are expressed
4545
* in pixel values.
4646
* @property {PIXI.Point} pivot
4747
* @default
4848
*/
49-
this.pivot = new PIXI.Point(0, 0);
49+
this.pivot = new Phaser.Point(0, 0);
5050

5151
/**
5252
* The rotation of this DisplayObject. The value is given, and expressed, in radians, and is based on
@@ -160,7 +160,7 @@ PIXI.DisplayObject = function () {
160160
* @property {PIXI.Point} worldPosition
161161
* @readOnly
162162
*/
163-
this.worldPosition = new PIXI.Point(0, 0);
163+
this.worldPosition = new Phaser.Point(0, 0);
164164

165165
/**
166166
* The global scale of this DisplayObject.
@@ -175,7 +175,7 @@ PIXI.DisplayObject = function () {
175175
* @property {PIXI.Point} worldScale
176176
* @readOnly
177177
*/
178-
this.worldScale = new PIXI.Point(1, 1);
178+
this.worldScale = new Phaser.Point(1, 1);
179179

180180
/**
181181
* The rotation, in radians, of this DisplayObject.
@@ -217,7 +217,7 @@ PIXI.DisplayObject = function () {
217217
* @property {PIXI.Rectangle} _bounds - The cached bounds of this object.
218218
* @private
219219
*/
220-
this._bounds = new PIXI.Rectangle(0, 0, 0, 0);
220+
this._bounds = new Phaser.Rectangle(0, 0, 0, 0);
221221

222222
/**
223223
* @property {PIXI.Rectangle} _currentBounds - The most recently calculated bounds of this object.

0 commit comments

Comments
 (0)