Skip to content

Commit c2f624d

Browse files
committed
Adding in the State Manager.
1 parent 1bb711e commit c2f624d

6 files changed

Lines changed: 715 additions & 2 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: 'f71c8930-b620-11e6-b63f-ab05aca00975'
2+
build: '099b0010-b62f-11e6-b06a-d5df4eb4313b'
33
};
44
module.exports = CHECKSUM;

v3/src/const.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@ var CONST = {
44

55
AUTO: 0,
66
CANVAS: 1,
7-
WEBGL: 2
7+
WEBGL: 2,
8+
9+
blendModes: {
10+
NORMAL: 0,
11+
ADD: 1,
12+
MULTIPLY: 2,
13+
SCREEN: 3,
14+
OVERLAY: 4,
15+
DARKEN: 5,
16+
LIGHTEN: 6,
17+
COLOR_DODGE: 7,
18+
COLOR_BURN: 8,
19+
HARD_LIGHT: 9,
20+
SOFT_LIGHT: 10,
21+
DIFFERENCE: 11,
22+
EXCLUSION: 12,
23+
HUE: 13,
24+
SATURATION: 14,
25+
COLOR: 15,
26+
LUMINOSITY: 16
27+
},
28+
29+
scaleModes: {
30+
DEFAULT: 0,
31+
LINEAR: 0,
32+
NEAREST: 1
33+
}
834

935
};
1036

v3/src/state/STATE_CONST.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var STATE_CONST = {
2+
3+
PENDING: 0,
4+
INSTALLED: 1,
5+
6+
BOOT: 0,
7+
INIT: 1,
8+
PRELOAD: 2,
9+
CREATE: 3,
10+
UPDATE: 4,
11+
RENDER: 5,
12+
SHUTDOWN: 6
13+
14+
};
15+
16+
module.exports = STATE_CONST;

v3/src/state/Settings.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var CONST = require('../CONST');
2+
var STATE_CONST = require('./STATE_CONST');
3+
var GetObjectValue = require('../utils/GetObjectValue');
4+
5+
var Settings = function (state, config)
6+
{
7+
if (typeof config === 'string')
8+
{
9+
config = { key: config };
10+
}
11+
else if (config === undefined)
12+
{
13+
// Pass the 'hasOwnProperty' checks
14+
config = {};
15+
}
16+
17+
this.state = state; // Do we actually need this reference? This could just be a property bucket
18+
19+
this.status = STATE_CONST.PENDING;
20+
21+
// Which part of this State is currently being processed?
22+
// preload, create, update, shutdown, etc
23+
this.op = STATE_CONST.BOOT;
24+
25+
this.key = GetObjectValue(config, 'key', '');
26+
this.active = GetObjectValue(config, 'active', false);
27+
this.visible = GetObjectValue(config, 'visible', true);
28+
this.scaleMode = GetObjectValue(config, 'scaleMode', CONST.scaleModes.DEFAULT);
29+
this.fps = GetObjectValue(config, 'fps', 60);
30+
this.x = GetObjectValue(config, 'x', 0);
31+
this.y = GetObjectValue(config, 'y', 0);
32+
33+
// -1 means the State Manager will set it to be the Game dimensions
34+
this.width = GetObjectValue(config, 'width', -1);
35+
this.height = GetObjectValue(config, 'height', -1);
36+
};
37+
38+
// Unless we add some actual functions in here, we'll make this just return an Object instead of an instance
39+
Settings.prototype.constructor = Settings;
40+
41+
module.exports = Settings;

v3/src/state/State.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 Settings = require('./Settings');
8+
var Systems = require('./Systems');
9+
10+
/**
11+
* A Base State Class.
12+
*
13+
* @class Phaser.State
14+
* @constructor
15+
*/
16+
var State = function (config)
17+
{
18+
// The properties a State *must* have, that cannot be changed without breaking it:
19+
20+
this.game = null;
21+
22+
this.settings = new Settings(this, config);
23+
24+
this.sys = new Systems(this, config);
25+
26+
// Reference to sys.children, set during sys.init only
27+
this.children;
28+
};
29+
30+
State.prototype.constructor = State;
31+
32+
State.prototype = {
33+
34+
// Can be overridden by your own States
35+
preUpdate: function ()
36+
{
37+
},
38+
39+
// Can be overridden by your own States
40+
update: function ()
41+
{
42+
},
43+
44+
// Can be overridden by your own States
45+
postUpdate: function ()
46+
{
47+
},
48+
49+
// Can be overridden by your own States
50+
render: function ()
51+
{
52+
}
53+
54+
};
55+
56+
module.exports = State;

0 commit comments

Comments
 (0)