phaser/src/scene/global/GlobalSceneManager.js

90 lines
3 KiB
JavaScript
Raw Normal View History

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: require('./inc/Add'),
boot: require('./inc/Boot'),
bootScene: require('./inc/BootScene'),
bringToTop: require('./inc/BringToTop'),
create: require('./inc/Create'),
createSceneDisplay: require('./inc/CreateSceneDisplay'),
createSceneFromFunction: require('./inc/CreateSceneFromFunction'),
createSceneFromInstance: require('./inc/CreateSceneFromInstance'),
createSceneFromObject: require('./inc/CreateSceneFromObject'),
getActiveScene: require('./inc/GetActiveScene'),
getActiveSceneIndex: require('./inc/GetActiveSceneIndex'),
getActiveSceneIndexByKey: require('./inc/GetActiveSceneIndexByKey'),
getKey: require('./inc/GetKey'),
getScene: require('./inc/GetScene'),
getSceneAt: require('./inc/GetSceneAt'),
getSceneIndex: require('./inc/GetSceneIndex'),
getSceneIndexByKey: require('./inc/GetSceneIndexByKey'),
isActive: require('./inc/IsActive'),
isSleeping: require('./inc/IsSleeping'),
loadComplete: require('./inc/LoadComplete'),
moveDown: require('./inc/MoveDown'),
moveUp: require('./inc/MoveUp'),
pause: require('./inc/Pause'),
payloadComplete: require('./inc/PayloadComplete'),
resume: require('./inc/Resume'),
sendToBack: require('./inc/SendToBack'),
sleep: require('./inc/Sleep'),
start: require('./inc/Start'),
stop: require('./inc/Stop'),
swap: require('./inc/Swap'),
swapPosition: require('./inc/SwapPosition'),
wake: require('./inc/Wake')
2016-11-29 13:01:16 +00:00
});
2016-11-29 13:01:16 +00:00
module.exports = GlobalSceneManager;