phaser/v3/src/state/systems/StateManager.js

80 lines
1.3 KiB
JavaScript
Raw Normal View History

// 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)
{
if (key === undefined) { key = this.key; }
2017-02-17 02:07:56 +00:00
this.manager.start(key, data);
},
// 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;