Fixed States from instances.

This commit is contained in:
Richard Davey 2017-02-06 23:59:15 +00:00
parent 00f9bcb8e2
commit c2657f3d19
5 changed files with 63 additions and 42 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: 'f3375a50-ec87-11e6-853a-69675ac00795'
build: '14193730-ecc8-11e6-9098-0597fdc18cfd'
};
module.exports = CHECKSUM;

View file

@ -26,6 +26,8 @@ var Phaser = {
},
State: require('./state/State'),
Loader: {
ImageFile: require('./loader/filetypes/ImageFile')

View file

@ -2,7 +2,9 @@ var CONST = require('./const');
var ScaleModes = require('../renderer/ScaleModes');
var GetObjectValue = require('../utils/object/GetObjectValue');
var Settings = function (config, gameConfig)
var Settings = {
create: function (config)
{
if (typeof config === 'string')
{
@ -29,8 +31,8 @@ var Settings = function (config, gameConfig)
x: GetObjectValue(config, 'x', 0),
y: GetObjectValue(config, 'y', 0),
width: GetObjectValue(config, 'width', gameConfig.width),
height: GetObjectValue(config, 'height', gameConfig.height),
width: GetObjectValue(config, 'width', -1),
height: GetObjectValue(config, 'height', -1),
// Renderer Settings
@ -41,6 +43,21 @@ var Settings = function (config, gameConfig)
drawToPrimaryCanvas: GetObjectValue(config, 'drawToPrimaryCanvas', false)
};
},
init: function (config, gameConfig)
{
if (config.width === -1)
{
config.width = gameConfig.width;
}
if (config.height === -1)
{
config.height = gameConfig.height;
}
}
};
module.exports = Settings;

View file

@ -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);
}

View file

@ -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;