Skip to content

Commit 6585297

Browse files
committed
Lots of Math component exports added.
Restructured Phaser export file, finally removing it out of the Boot folder. Fixed several broken math functions.
1 parent dc5ddec commit 6585297

21 files changed

Lines changed: 221 additions & 63 deletions

File tree

v3/src/boot/Game.js

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

7-
var Device = require('../device');
87
var Config = require('./Config');
98
var DebugHeader = require('./DebugHeader');
10-
var CreateRenderer = require('./CreateRenderer');
9+
var Device = require('../device');
10+
11+
var AddToDOM = require('../dom/AddToDOM');
1112
var RequestAnimationFrame = require('../dom/RequestAnimationFrame');
1213
var DOMContentLoaded = require('../dom/DOMContentLoaded');
14+
15+
var CreateRenderer = require('./CreateRenderer');
1316
var RandomDataGenerator = require('../math/random-data-generator/RandomDataGenerator');
1417
var StateManager = require('../state/StateManager');
15-
var FactoryContainer = require('../gameobjects/FactoryContainer');
16-
var GameObjects = require('../gameobjects/');
1718
var TextureManager = require ('../textures/TextureManager');
18-
var AddToDOM = require('../dom/AddToDOM');
1919

2020
var Game = function (config)
2121
{
2222
this.config = new Config(config);
2323

24-
// Decide which of the following should be Game properties, or placed elsewhere ...
25-
2624
this.renderer = null;
2725
this.canvas = null;
2826
this.context = null;
2927

30-
/**
31-
* @property {string|HTMLElement} parent - The Games DOM parent.
32-
* @default
33-
*/
34-
this.parent = parent;
35-
3628
this.isBooted = false;
3729
this.isRunning = false;
3830

@@ -45,17 +37,12 @@ var Game = function (config)
4537
/**
4638
* @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager.
4739
*/
48-
this.textures = new TextureManager(this);
49-
50-
/**
51-
* @property {Phaser.UpdateManager} updates - Reference to the Phaser Update Manager.
52-
*/
53-
this.updates = null;
40+
this.textures = new TextureManager();
5441

5542
/**
5643
* @property {Phaser.Cache} cache - Reference to the assets cache.
5744
*/
58-
this.cache = null;
45+
// this.cache = new Cache();
5946

6047
/**
6148
* @property {Phaser.Input} input - Reference to the input manager
@@ -72,7 +59,7 @@ var Game = function (config)
7259
*/
7360
this.device = Device;
7461

75-
// More this somewhere else? Math perhaps? Doesn't need to be a Game level system.
62+
// Move this somewhere else? Math perhaps? Doesn't need to be a Game level system.
7663
this.rnd;
7764

7865
// Wait for the DOM Ready event, then call boot.

v3/src/boot/index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

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: '3ccb42b0-c0bb-11e6-b4bc-27e9a3360164'
2+
build: 'a4ceb980-c14e-11e6-a2dd-3f0865028f71'
33
};
44
module.exports = CHECKSUM;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2016 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
var CONST = require('../../const');
8+
var GameObject = require('../GameObject');
9+
var ContainerWebGLRenderer = require('./ContainerWebGLRenderer');
10+
var Children = require('../../components/Children');
11+
12+
var Container = function (state, parent, x, y)
13+
{
14+
GameObject.call(this, state, x, y, null, null, parent);
15+
16+
this.type = CONST.CONTAINER;
17+
18+
this.render = ContainerWebGLRenderer;
19+
20+
this.children = new Children(this);
21+
};
22+
23+
Container.prototype = Object.create(GameObject.prototype);
24+
Container.prototype.constructor = Container;
25+
26+
Container.prototype.preUpdate = function ()
27+
{
28+
if (this.parent)
29+
{
30+
this.color.worldAlpha = this.parent.color.worldAlpha;
31+
}
32+
33+
this.children.preUpdate();
34+
};
35+
36+
module.exports = Container;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2016 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
var Container = require('./Container');
8+
var FactoryContainer = require('../../gameobjects/FactoryContainer');
9+
10+
var ContainerFactory = {
11+
12+
KEY: 'container',
13+
14+
add: function (parent, x, y)
15+
{
16+
if (group === undefined) { group = this.state; }
17+
18+
return group.children.add(new Container(this.state, parent, x, y));
19+
},
20+
21+
make: function (parent, x, y)
22+
{
23+
return new Container(this.state, parent, x, y);
24+
}
25+
26+
};
27+
28+
module.exports = FactoryContainer.register(ContainerFactory);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
var ContainerWebGLRenderer = function (renderer, src, interpolationPercentage)
3+
{
4+
var frame = src.frame;
5+
var alpha = src.color.worldAlpha * 255 << 24;
6+
7+
// Skip rendering?
8+
9+
if (src.skipRender || !src.visible || alpha === 0 || src.children.list.length === 0)
10+
{
11+
return;
12+
}
13+
14+
// Render children
15+
for (var i = 0; i < src.children.list.length; i++)
16+
{
17+
var child = src.children.list[i];
18+
19+
child.render(renderer, child);
20+
}
21+
};
22+
23+
module.exports = ContainerWebGLRenderer;

v3/src/gameobjects/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Include all of the Game Object Factories
2-
//
3-
// This file should be linked to the specific build of Phaser, i.e. Phaser Nano won't require all GOs
42

53
require('./image/ImageFactory');
4+
require('./container/ContainerFactory');

v3/src/math/Average.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
var Average = function ()
1+
var Average = function (values)
22
{
33
var sum = 0;
4-
var len = arguments.length;
54

6-
for (var i = 0; i < len; i++)
5+
for (var i = 0; i < values.length; i++)
76
{
8-
sum += (+arguments[i]);
7+
sum += (+values[i]);
98
}
109

11-
return sum / len;
10+
return sum / values.length;
1211
};
1312

1413
module.exports = Average;

v3/src/math/angle/Between.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ var Between = function (x1, y1, x2, y2)
33
return Math.atan2(y2 - y1, x2 - x1);
44
};
55

6-
export.module = Between;
6+
module.exports = Between;

v3/src/math/angle/WrapDegrees.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var MathWrap from '../Wrap';
1+
var Wrap = require('../Wrap');
22

3-
var WrapDegrees (angle)
3+
var WrapDegrees = function (angle)
44
{
5-
return MathWrap(angle, -180, 180);
5+
return Wrap(angle, -180, 180);
66
};
77

88
module.exports = WrapDegrees;

0 commit comments

Comments
 (0)