phaser/v3/src/scene/global/GlobalSceneManager.js

92 lines
2.9 KiB
JavaScript
Raw Normal View History

var Components = require('./components/');
var Class = require('../../utils/Class');
2016-11-29 13:01:16 +00:00
var GlobalSceneManager = new Class({
2016-11-29 13:01:16 +00:00
initialize:
2016-11-29 13:01:16 +00:00
function GlobalSceneManager (game, sceneConfig)
{
this.game = game;
2016-11-29 13:01:16 +00:00
// Everything kept in here
this.keys = {};
this.scenes = [];
2016-11-29 13:01:16 +00:00
// Only active scenes are kept in here. They are moved here when started, and moved out when not.
// All scenes are stored in the scenes array, regardless of being active or not.
this.active = [];
// A scene pending to be added to the Scene Manager is stored in here until the manager has time to add it.
this._pending = [];
// An array of scenes waiting to be started once the game has booted
this._start = [];
if (sceneConfig)
2016-11-29 13:01:16 +00:00
{
if (Array.isArray(sceneConfig))
{
for (var i = 0; i < sceneConfig.length; i++)
{
// The i === 0 part just starts the first Scene given
this._pending.push({
index: i,
key: 'default',
scene: sceneConfig[i],
autoStart: (i === 0),
data: {}
});
}
}
else
2016-11-29 13:01:16 +00:00
{
this._pending.push({
index: 0,
key: 'default',
scene: sceneConfig,
autoStart: true,
2017-02-16 17:18:50 +00:00
data: {}
});
2016-11-29 13:01:16 +00:00
}
}
},
2016-11-29 13:01:16 +00:00
add: Components.Add,
boot: Components.Boot,
bootScene: Components.BootScene,
bringToTop: Components.BringToTop,
create: Components.Create,
createSceneDisplay: Components.CreateSceneDisplay,
createSceneFromFunction: Components.CreateSceneFromFunction,
createSceneFromInstance: Components.CreateSceneFromInstance,
createSceneFromObject: Components.CreateSceneFromObject,
getActiveScene: Components.GetActiveScene,
getActiveSceneIndex: Components.GetActiveSceneIndex,
getActiveSceneIndexByKey: Components.GetActiveSceneIndexByKey,
getKey: Components.GetKey,
getScene: Components.GetScene,
getSceneAt: Components.GetSceneAt,
getSceneIndex: Components.GetSceneIndex,
getSceneIndexByKey: Components.GetSceneIndexByKey,
isActive: Components.IsActive,
isSleeping: Components.IsSleeping,
loadComplete: Components.LoadComplete,
moveDown: Components.MoveDown,
moveUp: Components.MoveUp,
pause: Components.Pause,
payloadComplete: Components.PayloadComplete,
resume: Components.Resume,
sendToBack: Components.SendToBack,
setupCallbacks: Components.SetupCallbacks,
sleep: Components.Sleep,
start: Components.Start,
stop: Components.Stop,
swap: Components.Swap,
swapPosition: Components.SwapPosition,
wake: Components.Wake
2016-11-29 13:01:16 +00:00
});
2016-11-29 13:01:16 +00:00
module.exports = GlobalSceneManager;