mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Fixed States from instances.
This commit is contained in:
parent
00f9bcb8e2
commit
c2657f3d19
5 changed files with 63 additions and 42 deletions
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: 'f3375a50-ec87-11e6-853a-69675ac00795'
|
||||
build: '14193730-ecc8-11e6-9098-0597fdc18cfd'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -26,6 +26,8 @@ var Phaser = {
|
|||
|
||||
},
|
||||
|
||||
State: require('./state/State'),
|
||||
|
||||
Loader: {
|
||||
|
||||
ImageFile: require('./loader/filetypes/ImageFile')
|
||||
|
|
|
@ -2,45 +2,62 @@ var CONST = require('./const');
|
|||
var ScaleModes = require('../renderer/ScaleModes');
|
||||
var GetObjectValue = require('../utils/object/GetObjectValue');
|
||||
|
||||
var Settings = function (config, gameConfig)
|
||||
{
|
||||
if (typeof config === 'string')
|
||||
var Settings = {
|
||||
|
||||
create: function (config)
|
||||
{
|
||||
config = { key: config };
|
||||
}
|
||||
else if (config === undefined)
|
||||
if (typeof config === 'string')
|
||||
{
|
||||
config = { key: config };
|
||||
}
|
||||
else if (config === undefined)
|
||||
{
|
||||
// Pass the 'hasOwnProperty' checks
|
||||
config = {};
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
status: CONST.PENDING,
|
||||
|
||||
op: CONST.BOOT,
|
||||
|
||||
key: GetObjectValue(config, 'key', ''),
|
||||
active: GetObjectValue(config, 'active', false),
|
||||
visible: GetObjectValue(config, 'visible', true),
|
||||
scaleMode: GetObjectValue(config, 'scaleMode', ScaleModes.DEFAULT),
|
||||
|
||||
// -1 means the State Manager will set it to be the Game dimensions
|
||||
|
||||
x: GetObjectValue(config, 'x', 0),
|
||||
y: GetObjectValue(config, 'y', 0),
|
||||
width: GetObjectValue(config, 'width', -1),
|
||||
height: GetObjectValue(config, 'height', -1),
|
||||
|
||||
// Renderer Settings
|
||||
|
||||
clearBeforeRender: GetObjectValue(config, 'clearBeforeRender', true),
|
||||
transparent: GetObjectValue(config, 'transparent', false),
|
||||
autoResize: GetObjectValue(config, 'autoResize', false),
|
||||
roundPixels: GetObjectValue(config, 'roundPixels', false),
|
||||
drawToPrimaryCanvas: GetObjectValue(config, 'drawToPrimaryCanvas', false)
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
init: function (config, gameConfig)
|
||||
{
|
||||
// Pass the 'hasOwnProperty' checks
|
||||
config = {};
|
||||
if (config.width === -1)
|
||||
{
|
||||
config.width = gameConfig.width;
|
||||
}
|
||||
|
||||
if (config.height === -1)
|
||||
{
|
||||
config.height = gameConfig.height;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
status: CONST.PENDING,
|
||||
|
||||
op: CONST.BOOT,
|
||||
|
||||
key: GetObjectValue(config, 'key', ''),
|
||||
active: GetObjectValue(config, 'active', false),
|
||||
visible: GetObjectValue(config, 'visible', true),
|
||||
scaleMode: GetObjectValue(config, 'scaleMode', ScaleModes.DEFAULT),
|
||||
|
||||
// -1 means the State Manager will set it to be the Game dimensions
|
||||
|
||||
x: GetObjectValue(config, 'x', 0),
|
||||
y: GetObjectValue(config, 'y', 0),
|
||||
width: GetObjectValue(config, 'width', gameConfig.width),
|
||||
height: GetObjectValue(config, 'height', gameConfig.height),
|
||||
|
||||
// Renderer Settings
|
||||
|
||||
clearBeforeRender: GetObjectValue(config, 'clearBeforeRender', true),
|
||||
transparent: GetObjectValue(config, 'transparent', false),
|
||||
autoResize: GetObjectValue(config, 'autoResize', false),
|
||||
roundPixels: GetObjectValue(config, 'roundPixels', false),
|
||||
drawToPrimaryCanvas: GetObjectValue(config, 'drawToPrimaryCanvas', false)
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = Settings;
|
||||
|
|
|
@ -132,23 +132,25 @@ StateManager.prototype = {
|
|||
autoStart: autoStart
|
||||
});
|
||||
|
||||
// console.log('StateManager not yet booted, adding to list', this._pending.length);
|
||||
console.log('StateManager not yet booted, adding to list', this._pending.length);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('StateManager.add', key, stateConfig, autoStart);
|
||||
|
||||
key = this.getKey(key, stateConfig);
|
||||
|
||||
var newState;
|
||||
|
||||
if (stateConfig instanceof State)
|
||||
{
|
||||
// console.log('StateManager.add from instance', key);
|
||||
console.log('StateManager.add from instance', key);
|
||||
newState = this.createStateFromInstance(key, stateConfig);
|
||||
}
|
||||
else if (typeof stateConfig === 'object')
|
||||
{
|
||||
// console.log('StateManager.add from object', key);
|
||||
console.log('StateManager.add from object', key);
|
||||
|
||||
stateConfig.key = key;
|
||||
|
||||
|
@ -156,7 +158,7 @@ StateManager.prototype = {
|
|||
}
|
||||
else if (typeof stateConfig === 'function')
|
||||
{
|
||||
// console.log('StateManager.add from function', key);
|
||||
console.log('StateManager.add from function', key);
|
||||
|
||||
newState = this.createStateFromFunction(key, stateConfig);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ var Systems = function (state, config)
|
|||
|
||||
this.config = config;
|
||||
|
||||
this.settings;
|
||||
this.settings = Settings.create(config);
|
||||
|
||||
// CORE SYSTEMS / PROPERTIES
|
||||
|
||||
|
@ -58,7 +58,7 @@ Systems.prototype = {
|
|||
|
||||
this.game = game;
|
||||
|
||||
this.settings = Settings(this.config, this.game.config);
|
||||
Settings.init(this.settings, this.game.config);
|
||||
|
||||
this.cache = this.game.cache;
|
||||
this.textures = this.game.textures;
|
||||
|
|
Loading…
Reference in a new issue