Skip to content

Commit 275badf

Browse files
committed
Removed Phaser global use from modules.
1 parent 6585297 commit 275badf

6 files changed

Lines changed: 21 additions & 10 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'a4ceb980-c14e-11e6-a2dd-3f0865028f71'
2+
build: '33625460-c152-11e6-ae92-d150eb7215ee'
33
};
44
module.exports = CHECKSUM;

v3/src/components/Transform.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
var MATH_CONST = require('../math/const');
8+
var WrapAngle = require('../math/angle/Wrap');
9+
710
/**
811
* 2D Transformation Component.
912
*
@@ -787,12 +790,12 @@ Object.defineProperties(Transform.prototype, {
787790

788791
get: function ()
789792
{
790-
return Phaser.Math.wrapAngle(this.rotation * Phaser.Math.RAD_TO_DEG);
793+
return WrapAngle(this.rotation * MATH_CONST.RAD_TO_DEG);
791794
},
792795

793796
set: function (value)
794797
{
795-
this.rotation = Phaser.Math.wrapAngle(value) * Phaser.Math.DEG_TO_RAD;
798+
this.rotation = WrapAngle(value) * MATH_CONST.DEG_TO_RAD;
796799
}
797800

798801
},
@@ -816,7 +819,7 @@ Object.defineProperties(Transform.prototype, {
816819
this._rotation = value;
817820
this.dirty = true;
818821

819-
if (this._rotation % Phaser.Math.PI2)
822+
if (this._rotation % MATH_CONST.PI2)
820823
{
821824
this.cache.sr = Math.sin(this._rotation);
822825
this.cache.cr = Math.cos(this._rotation);

v3/src/gameobjects/GameObject.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
var CONST = require('../const');
8+
var MATH_CONST = require('../math/const');
89
var Component = require('../components');
10+
var WrapAngle = require('../math/angle/Wrap');
911

1012
/**
1113
* This is the base Game Object class that you can use when creating your own extended Game Objects.
@@ -280,12 +282,12 @@ Object.defineProperties(GameObject.prototype, {
280282

281283
get: function ()
282284
{
283-
return Phaser.Math.wrapAngle(this.rotation * Phaser.Math.RAD_TO_DEG);
285+
return WrapAngle(this.rotation * MATH_CONST.RAD_TO_DEG);
284286
},
285287

286288
set: function (value)
287289
{
288-
this.rotation = Phaser.Math.wrapAngle(value) * Phaser.Math.DEG_TO_RAD;
290+
this.rotation = WrapAngle(value) * MATH_CONST.DEG_TO_RAD;
289291
}
290292

291293
},
@@ -309,7 +311,7 @@ Object.defineProperties(GameObject.prototype, {
309311
this.transform._rotation = value;
310312
this.transform.dirty = true;
311313

312-
if (this.transform._rotation % Phaser.Math.PI2)
314+
if (this.transform._rotation % MATH_CONST.PI2)
313315
{
314316
this.transform.cache.sr = Math.sin(this.transform._rotation);
315317
this.transform.cache.cr = Math.cos(this.transform._rotation);

v3/src/gameobjects/container/ContainerFactory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ var ContainerFactory = {
1313

1414
add: function (parent, x, y)
1515
{
16-
if (group === undefined) { group = this.state; }
16+
if (parent === undefined) { parent = this.state; }
1717

18-
return group.children.add(new Container(this.state, parent, x, y));
18+
return parent.children.add(new Container(this.state, parent, x, y));
1919
},
2020

2121
make: function (parent, x, y)

v3/src/gameobjects/container/ContainerWebGLRenderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
var ContainerWebGLRenderer = function (renderer, src, interpolationPercentage)
33
{
4-
var frame = src.frame;
54
var alpha = src.color.worldAlpha * 255 << 24;
65

76
// Skip rendering?

v3/src/math/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
module.exports = {
22

3+
// CONSTs (makes them visible under Phaser.Math)
4+
PI2: Math.PI * 2,
5+
TAU: Math.PI * 0.5,
6+
EPSILON: 1.0e-6,
7+
DEG_TO_RAD: Math.PI / 180,
8+
RAD_TO_DEG: 180 / Math.PI,
9+
310
// Collections of functions
411
Angle: require('./angle/'),
512
Distance: require('./distance/'),

0 commit comments

Comments
 (0)