2017-07-11 15:48:25 +00:00
|
|
|
var Start = function (key, data)
|
|
|
|
{
|
|
|
|
if (data === undefined) { data = {}; }
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
// if not booted, then put scene into a holding pattern
|
2017-07-11 15:48:25 +00:00
|
|
|
if (!this.game.isBooted)
|
|
|
|
{
|
|
|
|
for (var i = 0; i < this._pending.length; i++)
|
|
|
|
{
|
|
|
|
var entry = this._pending[i];
|
|
|
|
|
|
|
|
if (entry.key === key)
|
|
|
|
{
|
|
|
|
entry.autoStart = true;
|
|
|
|
entry.data = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
var scene = this.getScene(key);
|
2017-07-11 15:48:25 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
if (scene)
|
2017-07-11 15:48:25 +00:00
|
|
|
{
|
|
|
|
// Already started? Nothing more to do here ...
|
|
|
|
if (this.isActive(key))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
scene.sys.start(data);
|
2017-07-11 15:48:25 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
var loader = scene.sys.load;
|
2017-07-11 15:48:25 +00:00
|
|
|
|
|
|
|
// Files payload?
|
2017-07-14 13:30:20 +00:00
|
|
|
if (loader && Array.isArray(scene.sys.settings.files))
|
2017-07-11 15:48:25 +00:00
|
|
|
{
|
|
|
|
loader.reset();
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
if (loader.loadArray(scene.sys.settings.files))
|
2017-07-11 15:48:25 +00:00
|
|
|
{
|
|
|
|
loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this));
|
|
|
|
|
|
|
|
loader.start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
this.bootScene(scene);
|
2017-07-11 15:48:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
this.bootScene(scene);
|
2017-07-11 15:48:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Start;
|