phaser/v3/src/scene/global/components/Start.js
Richard Davey 665b295c3b Restructured the Scene folder and moved the plugins and components around
Also updated the physicsManager to make it a lot more cleaner and easy to adjust in future
2017-08-18 01:42:14 +01:00

59 lines
1.2 KiB
JavaScript

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;