phaser/v3/src/scene/global/components/Start.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

var Start = function (key, data)
{
if (data === undefined) { data = {}; }
// if not booted, then put scene into a holding pattern
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;
}
var scene = this.getScene(key);
if (scene)
{
// Already started? Nothing more to do here ...
if (this.isActive(key))
{
return;
}
scene.sys.start(data);
var loader = scene.sys.load;
// Files payload?
if (loader && Array.isArray(scene.sys.settings.files))
{
loader.reset();
if (loader.loadArray(scene.sys.settings.files))
{
loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this));
loader.start();
}
else
{
this.bootScene(scene);
}
}
else
{
this.bootScene(scene);
}
}
};
module.exports = Start;