phaser/v3/src/state/Settings.js

51 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-01-20 02:28:55 +00:00
var CONST = require('./const');
2017-01-18 14:48:02 +00:00
var ScaleModes = require('../renderer/ScaleModes');
2016-11-29 13:01:16 +00:00
var GetObjectValue = require('../utils/GetObjectValue');
var Settings = function (state, config)
{
if (typeof config === 'string')
{
config = { key: config };
}
else if (config === undefined)
{
// Pass the 'hasOwnProperty' checks
config = {};
}
this.state = state; // Do we actually need this reference? This could just be a property bucket
2017-01-20 02:28:55 +00:00
this.status = CONST.PENDING;
2016-11-29 13:01:16 +00:00
// Which part of this State is currently being processed?
// preload, create, update, shutdown, etc
2017-01-20 02:28:55 +00:00
this.op = CONST.BOOT;
2016-11-29 13:01:16 +00:00
this.key = GetObjectValue(config, 'key', '');
this.active = GetObjectValue(config, 'active', false);
this.visible = GetObjectValue(config, 'visible', true);
2017-01-18 14:48:02 +00:00
this.scaleMode = GetObjectValue(config, 'scaleMode', ScaleModes.DEFAULT);
2016-11-29 13:01:16 +00:00
this.fps = GetObjectValue(config, 'fps', 60);
this.x = GetObjectValue(config, 'x', 0);
this.y = GetObjectValue(config, 'y', 0);
// -1 means the State Manager will set it to be the Game dimensions
this.width = GetObjectValue(config, 'width', -1);
this.height = GetObjectValue(config, 'height', -1);
2017-01-20 02:28:55 +00:00
// Renderer Settings
this.clearBeforeRender = GetObjectValue(config, 'clearBeforeRender', true);
this.transparent = GetObjectValue(config, 'transparent', false);
this.autoResize = GetObjectValue(config, 'autoResize', false);
this.roundPixels = GetObjectValue(config, 'roundPixels', false);
this.drawToPrimaryCanvas = GetObjectValue(config, 'drawToPrimaryCanvas', false);
2016-11-29 13:01:16 +00:00
};
// Unless we add some actual functions in here, we'll make this just return an Object instead of an instance
Settings.prototype.constructor = Settings;
module.exports = Settings;