Skip to content

Commit 44c87b1

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents 5ed40ae + d557d13 commit 44c87b1

13 files changed

Lines changed: 251 additions & 23 deletions

File tree

v3/src/boot/CreateRenderer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ var CreateRenderer = function (game)
6969
// game.context = this.renderer.context;
7070
}
7171

72-
if (config.renderType !== Phaser.HEADLESS)
73-
{
72+
// if (config.renderType !== Phaser.HEADLESS)
73+
// {
7474
// Phaser.Canvas.addToDOM(this.canvas, this.parent, false);
7575
// Phaser.Canvas.setTouchAction(this.canvas);
76-
}
76+
// }
7777

7878
};
7979

v3/src/camera/Camera.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
var Component = require('../components');
8+
var MATH_CONST = require('../math/const');
9+
var WrapAngle = require('../math/angle/Wrap');
810

911
/**
1012
* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
@@ -292,12 +294,12 @@ Object.defineProperties(Camera.prototype, {
292294

293295
get: function ()
294296
{
295-
return Phaser.Math.wrapAngle(this.rotation * Phaser.Math.RAD_TO_DEG);
297+
return WrapAngle(this.rotation * MATH_CONST.RAD_TO_DEG);
296298
},
297299

298300
set: function (value)
299301
{
300-
this.rotation = Phaser.Math.wrapAngle(value) * Phaser.Math.DEG_TO_RAD;
302+
this.rotation = WrapAngle(value) * MATH_CONST.DEG_TO_RAD;
301303
}
302304

303305
},
@@ -321,7 +323,7 @@ Object.defineProperties(Camera.prototype, {
321323
this.transform._rotation = value;
322324
this.transform.dirty = true;
323325

324-
if (this.transform._rotation % Phaser.Math.PI2)
326+
if (this.transform._rotation % MATH_CONST.PI2)
325327
{
326328
this.transform.cache.sr = Math.sin(this.transform._rotation);
327329
this.transform.cache.cr = Math.cos(this.transform._rotation);
@@ -334,7 +336,7 @@ Object.defineProperties(Camera.prototype, {
334336
}
335337
}
336338

337-
}
339+
},
338340

339341
});
340342

v3/src/math/angle/RotateTo.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var MATH_CONST = require('../const');
2+
13
/**
24
* Rotates currentAngle towards targetAngle, taking the shortest rotation distance.
35
* The lerp argument is the amount to rotate by in this call.
@@ -17,7 +19,7 @@ var RotateTo = function (currentAngle, targetAngle, lerp)
1719
return currentAngle;
1820
}
1921

20-
if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (Phaser.Math.PI2 - lerp))
22+
if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp))
2123
{
2224
currentAngle = targetAngle;
2325
}
@@ -27,11 +29,11 @@ var RotateTo = function (currentAngle, targetAngle, lerp)
2729
{
2830
if (targetAngle < currentAngle)
2931
{
30-
targetAngle += Phaser.Math.PI2;
32+
targetAngle += MATH_CONST.PI2;
3133
}
3234
else
3335
{
34-
targetAngle -= Phaser.Math.PI2;
36+
targetAngle -= MATH_CONST.PI2;
3537
}
3638
}
3739

v3/src/phaser.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ var Phaser = {
2121

2222
ImageFile: require('./loader/filetypes/ImageFile')
2323

24+
},
25+
26+
Utils: {
27+
28+
Array: require('./utils/array/'),
29+
Objects: require('./utils/objects/')
30+
2431
}
2532

2633
};

v3/src/textures/Frame.js

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

7+
var Extend = require('../utils/object/Extend');
8+
79
/**
810
* A Frame is a section of a Texture.
911
*
@@ -242,7 +244,7 @@ Frame.prototype = {
242244

243245
clone: function ()
244246
{
245-
var clone = new Phaser.TextureFrame(this.texture, this.name, this.sourceIndex);
247+
var clone = new Frame(this.texture, this.name, this.sourceIndex);
246248

247249
clone.cutX = this.cutX;
248250
clone.cutY = this.cutY;
@@ -256,7 +258,7 @@ Frame.prototype = {
256258

257259
clone.rotated = this.rotated;
258260

259-
clone.data = Phaser.Utils.extend(true, clone.data, this.data);
261+
clone.data = Extend(true, clone.data, this.data);
260262

261263
clone.updateUVs();
262264

v3/src/utils/array/matrix/MatrixToString.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import Pad from 'utils/string/Pad.js';
2-
import CheckMatrix from 'utils/array/matrix/CheckMatrix.js';
1+
var Pad = require('../../string/Pad');
2+
var CheckMatrix = require('./CheckMatrix');
33

44
// Generates a string (which you can pass to console.log) from the given
55
// Array Matrix.
66

7-
export default function MatrixToString (matrix) {
8-
9-
let str = '';
7+
var MatrixToString = function (matrix)
8+
{
9+
var str = '';
1010

1111
if (!CheckMatrix(matrix))
1212
{
1313
return str;
1414
}
1515

16-
for (let r = 0; r < matrix.length; r++)
16+
for (var r = 0; r < matrix.length; r++)
1717
{
18-
for (let c = 0; c < matrix[r].length; c++)
18+
for (var c = 0; c < matrix[r].length; c++)
1919
{
20-
let cell = matrix[r][c].toString();
20+
var cell = matrix[r][c].toString();
2121

2222
if (cell !== 'undefined')
2323
{
@@ -38,7 +38,7 @@ export default function MatrixToString (matrix) {
3838
{
3939
str += '\n';
4040

41-
for (let i = 0; i < matrix[r].length; i++)
41+
for (var i = 0; i < matrix[r].length; i++)
4242
{
4343
str += '---';
4444

@@ -54,5 +54,6 @@ export default function MatrixToString (matrix) {
5454
}
5555

5656
return str;
57+
};
5758

58-
}
59+
module.exports = MatrixToString;

v3/src/utils/array/matrix/ReverseColumns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var ReverseColumns = function (matrix)
22
{
3-
for (let i = 0; i < matrix.length; i++)
3+
for (var i = 0; i < matrix.length; i++)
44
{
55
matrix[i].reverse();
66
}

v3/src/utils/array/matrix/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
3+
CheckMatrix: require('./CheckMatrix'),
4+
MatrixToString: require('./MatrixToString'),
5+
ReverseColumns: require('./ReverseColumns'),
6+
ReverseRows: require('./ReverseRows'),
7+
Rotate180: require('./Rotate180'),
8+
RotateLeft: require('./RotateLeft'),
9+
RotateMatrix: require('./RotateMatrix'),
10+
RotateRight: require('./RotateRight'),
11+
TransposeMatrix: require('./TransposeMatrix')
12+
13+
};

v3/src/utils/object/Extend.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
var IsPlainObject = require('./IsPlainObject');
2+
3+
/**
4+
* This is a slightly modified version of http://api.jquery.com/jQuery.extend/
5+
*
6+
* @method Phaser.Utils.extend
7+
* @param {boolean} deep - Perform a deep copy?
8+
* @param {object} target - The target object to copy to.
9+
* @return {object} The extended object.
10+
*/
11+
var extend = function ()
12+
{
13+
var options, name, src, copy, copyIsArray, clone,
14+
target = arguments[0] || {},
15+
i = 1,
16+
length = arguments.length,
17+
deep = false;
18+
19+
// Handle a deep copy situation
20+
if (typeof target === "boolean")
21+
{
22+
deep = target;
23+
target = arguments[1] || {};
24+
// skip the boolean and the target
25+
i = 2;
26+
}
27+
28+
// extend Phaser if only one argument is passed
29+
if (length === i)
30+
{
31+
target = this;
32+
--i;
33+
}
34+
35+
for (; i < length; i++)
36+
{
37+
// Only deal with non-null/undefined values
38+
if ((options = arguments[i]) != null)
39+
{
40+
// Extend the base object
41+
for (name in options)
42+
{
43+
src = target[name];
44+
copy = options[name];
45+
46+
// Prevent never-ending loop
47+
if (target === copy)
48+
{
49+
continue;
50+
}
51+
52+
// Recurse if we're merging plain objects or arrays
53+
if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy))))
54+
{
55+
if (copyIsArray)
56+
{
57+
copyIsArray = false;
58+
clone = src && Array.isArray(src) ? src : [];
59+
}
60+
else
61+
{
62+
clone = src && IsPlainObject(src) ? src : {};
63+
}
64+
65+
// Never move original objects, clone them
66+
target[name] = Extend(deep, clone, copy);
67+
68+
// Don't bring in undefined values
69+
}
70+
else if (copy !== undefined)
71+
{
72+
target[name] = copy;
73+
}
74+
}
75+
}
76+
}
77+
78+
// Return the modified object
79+
return target;
80+
};
81+
82+
module.exports = Extend;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* This is a slightly modified version of jQuery.isPlainObject.
3+
* A plain object is an object whose internal class property is [object Object].
4+
* @method Phaser.Utils.isPlainObject
5+
* @param {object} obj - The object to inspect.
6+
* @return {boolean} - true if the object is plain, otherwise false.
7+
*/
8+
var IsPlainObject = function (obj)
9+
{
10+
// Not plain objects:
11+
// - Any object or value whose internal [[Class]] property is not "[object Object]"
12+
// - DOM nodes
13+
// - window
14+
if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window)
15+
{
16+
return false;
17+
}
18+
19+
// Support: Firefox <20
20+
// The try/catch suppresses exceptions thrown when attempting to access
21+
// the "constructor" property of certain host objects, ie. |window.location|
22+
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
23+
try {
24+
if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf"))
25+
{
26+
return false;
27+
}
28+
} catch (e) {
29+
return false;
30+
}
31+
32+
// If the function hasn't returned already, we're confident that
33+
// |obj| is a plain object, created by {} or constructed with new Object
34+
return true;
35+
};
36+
37+
module.exports = IsPlainObject;

0 commit comments

Comments
 (0)