2017-02-08 01:07:01 +00:00
|
|
|
// A proxy class to the Global State Manager
|
|
|
|
|
|
|
|
var StateManager = function (state, game)
|
|
|
|
{
|
|
|
|
// The State that owns this StateManager
|
|
|
|
this.state = state;
|
|
|
|
|
|
|
|
this.key = state.sys.settings.key;
|
|
|
|
|
|
|
|
// GlobalStateManager
|
|
|
|
this.manager = game.state;
|
|
|
|
};
|
|
|
|
|
|
|
|
StateManager.prototype.constructor = StateManager;
|
|
|
|
|
|
|
|
StateManager.prototype = {
|
|
|
|
|
|
|
|
// Start this State (or the one given via key)
|
2017-02-17 02:07:56 +00:00
|
|
|
start: function (key, data)
|
2017-02-08 01:07:01 +00:00
|
|
|
{
|
|
|
|
if (key === undefined) { key = this.key; }
|
|
|
|
|
2017-02-17 02:07:56 +00:00
|
|
|
this.manager.start(key, data);
|
2017-02-08 01:07:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Pause this State (or the one given via key)
|
|
|
|
pause: function (key)
|
|
|
|
{
|
|
|
|
if (key === undefined) { key = this.key; }
|
|
|
|
|
|
|
|
this.manager.pause(key);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Stop this State and start the one given
|
|
|
|
swap: function (key)
|
|
|
|
{
|
|
|
|
this.manager.pause(this.key);
|
|
|
|
|
|
|
|
this.manager.start(key);
|
|
|
|
},
|
|
|
|
|
|
|
|
moveUp: function ()
|
|
|
|
{
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
moveDown: function ()
|
|
|
|
{
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
bringToTop: function ()
|
|
|
|
{
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
sendToBack: function ()
|
|
|
|
{
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
transitionTo: function (key, duration)
|
|
|
|
{
|
|
|
|
this.manager.pause(this.key);
|
|
|
|
|
|
|
|
this.manager.start(key);
|
|
|
|
},
|
|
|
|
|
|
|
|
isActive: function (key)
|
|
|
|
{
|
|
|
|
if (key === undefined) { key = this.key; }
|
|
|
|
|
|
|
|
return this.manager.isActive(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = StateManager;
|