2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-01-12 17:09:09 +00:00
|
|
|
var Class = require('../utils/Class');
|
2016-12-06 15:15:42 +00:00
|
|
|
var CONST = require('./const');
|
2017-10-04 22:48:16 +00:00
|
|
|
var CustomSet = require('../structs/Set');
|
2018-01-12 17:09:09 +00:00
|
|
|
var EventEmitter = require('eventemitter3');
|
2018-01-19 14:47:16 +00:00
|
|
|
var FileTypesManager = require('./FileTypesManager');
|
2018-01-19 16:56:41 +00:00
|
|
|
var GetFastValue = require('../utils/object/GetFastValue');
|
2018-01-19 14:54:50 +00:00
|
|
|
var ParseXMLBitmapFont = require('../gameobjects/bitmaptext/ParseXMLBitmapFont');
|
2018-02-12 23:03:48 +00:00
|
|
|
var PluginManager = require('../boot/PluginManager');
|
2018-01-19 14:54:50 +00:00
|
|
|
var XHRSettings = require('./XHRSettings');
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-03-23 15:54:12 +00:00
|
|
|
/**
|
|
|
|
* @typedef {object} LinkFileObject
|
|
|
|
*
|
|
|
|
* @property {string} type - [description]
|
|
|
|
* @property {Phaser.Loader.File} fileA - [description]
|
|
|
|
* @property {Phaser.Loader.File} fileB - [description]
|
|
|
|
*/
|
|
|
|
|
2018-03-22 12:51:30 +00:00
|
|
|
/**
|
|
|
|
* @typedef {object} LoaderFileObject
|
|
|
|
*
|
|
|
|
* @property {string} key - [description]
|
|
|
|
* @property {string} type - [description]
|
|
|
|
* @property {string} [url] - [description]
|
|
|
|
* @property {string[]} [urls] - [description]
|
|
|
|
* @property {string} [textureURL] - [description]
|
|
|
|
* @property {string} [atlasURL] - [description]
|
|
|
|
* @property {string} [xmlURL] - [description]
|
|
|
|
* @property {string[]} [textureURLs] - [description]
|
|
|
|
* @property {string[]} [atlasURLs] - [description]
|
|
|
|
* @property {object} [config] - [description]
|
|
|
|
* @property {object} [json] - [description]
|
|
|
|
* @property {XHRSettingsObject} [xhrSettings] - [description]
|
|
|
|
* @property {XHRSettingsObject} [textureXhrSettings] - [description]
|
|
|
|
* @property {XHRSettingsObject} [atlasXhrSettings] - [description]
|
|
|
|
* @property {XHRSettingsObject} [xmlXhrSettings] - [description]
|
|
|
|
* @property {XHRSettingsObject} [audioXhrSettings] - [description]
|
|
|
|
* @property {XHRSettingsObject} [jsonXhrSettings] - [description]
|
|
|
|
*/
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @class LoaderPlugin
|
2018-03-28 14:04:09 +00:00
|
|
|
* @extends Phaser.Events.EventEmitter
|
2018-02-09 17:56:43 +00:00
|
|
|
* @memberOf Phaser.Loader
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scene} scene - [description]
|
|
|
|
*/
|
2018-01-19 14:54:50 +00:00
|
|
|
var LoaderPlugin = new Class({
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-12 17:09:09 +00:00
|
|
|
Extends: EventEmitter,
|
|
|
|
|
2017-07-03 15:05:22 +00:00
|
|
|
initialize:
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-19 14:54:50 +00:00
|
|
|
function LoaderPlugin (scene)
|
2017-07-03 15:05:22 +00:00
|
|
|
{
|
2018-01-12 17:09:09 +00:00
|
|
|
EventEmitter.call(this);
|
2017-08-04 17:43:05 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#scene
|
|
|
|
* @type {Phaser.Scene}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-12 17:09:09 +00:00
|
|
|
this.scene = scene;
|
2017-07-03 15:05:22 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#systems
|
|
|
|
* @type {Phaser.Scenes.Systems}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 14:47:16 +00:00
|
|
|
this.systems = scene.sys;
|
|
|
|
|
|
|
|
if (!scene.sys.settings.isBooted)
|
|
|
|
{
|
|
|
|
scene.sys.events.once('boot', this.boot, this);
|
|
|
|
}
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#_multilist
|
|
|
|
* @type {object}
|
|
|
|
* @private
|
|
|
|
* @default {}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 14:47:16 +00:00
|
|
|
this._multilist = {};
|
|
|
|
|
|
|
|
// Inject the available filetypes into the Loader
|
|
|
|
FileTypesManager.install(this);
|
|
|
|
|
2018-01-19 16:56:41 +00:00
|
|
|
var gameConfig = this.systems.game.config;
|
2018-01-19 17:07:38 +00:00
|
|
|
var sceneConfig = this.systems.settings.loader;
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#path
|
|
|
|
* @type {string}
|
|
|
|
* @default ''
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 17:07:38 +00:00
|
|
|
this.path = '';
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#baseURL
|
|
|
|
* @type {string}
|
|
|
|
* @default ''
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 17:07:38 +00:00
|
|
|
this.baseURL = '';
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-19 17:10:23 +00:00
|
|
|
this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL));
|
2018-02-09 17:56:43 +00:00
|
|
|
|
2018-01-19 17:07:38 +00:00
|
|
|
this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath));
|
2018-01-19 16:56:41 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#enableParallel
|
|
|
|
* @type {boolean}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel);
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#maxParallelDownloads
|
|
|
|
* @type {integer}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* xhr specific global settings (can be overridden on a per-file basis)
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#xhr
|
2018-03-21 12:03:14 +00:00
|
|
|
* @type {XHRSettingsObject}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.xhr = XHRSettings(
|
|
|
|
GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType),
|
|
|
|
GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync),
|
|
|
|
GetFastValue(sceneConfig, 'user', gameConfig.loaderUser),
|
|
|
|
GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword),
|
|
|
|
GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout)
|
|
|
|
);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#crossOrigin
|
|
|
|
* @type {string}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#totalToLoad
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:28:59 +00:00
|
|
|
this.totalToLoad = 0;
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#progress
|
|
|
|
* @type {number}
|
|
|
|
* @default 0
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 16:28:59 +00:00
|
|
|
this.progress = 0;
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#list
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.Set.<Phaser.Loader.File>}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-04 22:48:16 +00:00
|
|
|
this.list = new CustomSet();
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#inflight
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.Set.<Phaser.Loader.File>}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-04 22:48:16 +00:00
|
|
|
this.inflight = new CustomSet();
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#failed
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.Set.<Phaser.Loader.File>}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-04 22:48:16 +00:00
|
|
|
this.failed = new CustomSet();
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#queue
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.Set.<Phaser.Loader.File>}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-04 22:48:16 +00:00
|
|
|
this.queue = new CustomSet();
|
2018-02-09 17:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#storage
|
2018-03-23 15:54:12 +00:00
|
|
|
* @type {Phaser.Structs.Set.<(Phaser.Loader.File|LinkFileObject)>}
|
2018-02-09 17:56:43 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-10-04 22:48:16 +00:00
|
|
|
this.storage = new CustomSet();
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Loader.LoaderPlugin#state
|
|
|
|
* @type {integer}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_IDLE;
|
2017-07-03 15:05:22 +00:00
|
|
|
},
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#boot
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 14:47:16 +00:00
|
|
|
boot: function ()
|
|
|
|
{
|
|
|
|
var eventEmitter = this.systems.events;
|
|
|
|
|
|
|
|
eventEmitter.on('shutdown', this.shutdown, this);
|
|
|
|
eventEmitter.on('destroy', this.destroy, this);
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#setBaseURL
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} url - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
|
|
|
|
*/
|
2018-01-19 16:28:59 +00:00
|
|
|
setBaseURL: function (url)
|
|
|
|
{
|
2018-01-19 17:28:48 +00:00
|
|
|
if (url !== '' && url.substr(-1) !== '/')
|
2018-01-19 17:10:23 +00:00
|
|
|
{
|
|
|
|
url = url.concat('/');
|
|
|
|
}
|
|
|
|
|
2018-01-19 16:28:59 +00:00
|
|
|
this.baseURL = url;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#setPath
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} path - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
|
|
|
|
*/
|
2017-08-04 15:15:00 +00:00
|
|
|
setPath: function (path)
|
|
|
|
{
|
2018-01-19 17:28:48 +00:00
|
|
|
if (path !== '' && path.substr(-1) !== '/')
|
2017-08-04 15:15:00 +00:00
|
|
|
{
|
|
|
|
path = path.concat('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.path = path;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-13 05:54:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#setCORS
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} crossOrigin - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
|
|
|
|
*/
|
|
|
|
setCORS: function (crossOrigin)
|
|
|
|
{
|
|
|
|
this.crossOrigin = crossOrigin;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#addFile
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} file - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.File} [description]
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
addFile: function (file)
|
|
|
|
{
|
|
|
|
if (!this.isReady())
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-12-12 22:27:53 +00:00
|
|
|
file.path = this.path;
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2016-12-12 22:35:47 +00:00
|
|
|
this.list.set(file);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-29 23:38:27 +00:00
|
|
|
return file;
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* Is the Loader actively loading (or processing loaded files)
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#isLoading
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
isLoading: function ()
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING);
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* Is the Loader ready to start a new load?
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#isReady
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
isReady: function ()
|
|
|
|
{
|
2018-04-09 12:55:41 +00:00
|
|
|
return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE);
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#start
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
start: function ()
|
|
|
|
{
|
|
|
|
if (!this.isReady())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-19 16:28:59 +00:00
|
|
|
this.progress = 0;
|
|
|
|
this.totalToLoad = this.list.size;
|
|
|
|
|
2018-01-12 17:09:09 +00:00
|
|
|
this.emit('start', this);
|
2016-12-05 17:19:12 +00:00
|
|
|
|
2016-11-30 17:16:45 +00:00
|
|
|
if (this.list.size === 0)
|
|
|
|
{
|
|
|
|
this.finishedLoading();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_LOADING;
|
2016-11-30 17:16:45 +00:00
|
|
|
|
|
|
|
this.failed.clear();
|
|
|
|
this.inflight.clear();
|
|
|
|
this.queue.clear();
|
|
|
|
|
2016-12-08 16:21:16 +00:00
|
|
|
this.queue.debug = true;
|
|
|
|
|
2016-11-30 17:16:45 +00:00
|
|
|
this.updateProgress();
|
|
|
|
|
|
|
|
this.processLoadQueue();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#updateProgress
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
updateProgress: function ()
|
|
|
|
{
|
2018-03-16 15:01:39 +00:00
|
|
|
this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-19 16:28:59 +00:00
|
|
|
this.emit('progress', this.progress);
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#processLoadQueue
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
processLoadQueue: function ()
|
|
|
|
{
|
|
|
|
this.list.each(function (file)
|
|
|
|
{
|
2018-01-19 17:53:07 +00:00
|
|
|
if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads))
|
2016-11-30 17:16:45 +00:00
|
|
|
{
|
2017-10-04 22:48:16 +00:00
|
|
|
this.inflight.set(file);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
this.list.delete(file);
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
this.loadFile(file);
|
2016-11-30 17:16:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
if (this.inflight.size === this.maxParallelDownloads)
|
2016-11-30 17:16:45 +00:00
|
|
|
{
|
|
|
|
// Tells the Set iterator to abort
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
}, this);
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#loadFile
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} file - [description]
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
loadFile: function (file)
|
|
|
|
{
|
|
|
|
// If the file doesn't have its own crossOrigin set,
|
|
|
|
// we'll use the Loaders (which is undefined by default)
|
|
|
|
if (!file.crossOrigin)
|
|
|
|
{
|
|
|
|
file.crossOrigin = this.crossOrigin;
|
|
|
|
}
|
|
|
|
|
2018-01-19 19:13:27 +00:00
|
|
|
file.load(this);
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#nextFile
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} previousFile - [description]
|
|
|
|
* @param {boolean} success - [description]
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
nextFile: function (previousFile, success)
|
|
|
|
{
|
|
|
|
// Move the file that just loaded from the inflight list to the queue or failed Set
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
2018-01-19 16:28:59 +00:00
|
|
|
this.emit('load', previousFile);
|
2016-12-12 22:35:47 +00:00
|
|
|
this.queue.set(previousFile);
|
2016-11-30 17:16:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-19 16:28:59 +00:00
|
|
|
this.emit('loaderror', previousFile);
|
2016-12-12 22:35:47 +00:00
|
|
|
this.failed.set(previousFile);
|
2016-11-30 17:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.inflight.delete(previousFile);
|
|
|
|
|
2018-01-19 16:28:59 +00:00
|
|
|
this.updateProgress();
|
|
|
|
|
2016-11-30 17:16:45 +00:00
|
|
|
if (this.list.size > 0)
|
|
|
|
{
|
|
|
|
this.processLoadQueue();
|
|
|
|
}
|
|
|
|
else if (this.inflight.size === 0)
|
|
|
|
{
|
|
|
|
this.finishedLoading();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#finishedLoading
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
finishedLoading: function ()
|
|
|
|
{
|
2018-01-19 16:28:59 +00:00
|
|
|
if (this.state === CONST.LOADER_PROCESSING)
|
2018-01-08 16:38:56 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-19 16:28:59 +00:00
|
|
|
this.progress = 1;
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_PROCESSING;
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2016-12-08 16:21:16 +00:00
|
|
|
this.storage.clear();
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-19 17:28:48 +00:00
|
|
|
if (this.queue.size === 0)
|
2016-11-30 17:16:45 +00:00
|
|
|
{
|
2018-01-19 17:28:48 +00:00
|
|
|
// Everything failed, so nothing to process
|
|
|
|
this.processComplete();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.queue.each(function (file)
|
|
|
|
{
|
|
|
|
file.onProcess(this.processUpdate.bind(this));
|
|
|
|
}, this);
|
|
|
|
}
|
2016-12-07 00:27:56 +00:00
|
|
|
},
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* Called automatically by the File when it has finished processing.
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#processUpdate
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} file - [description]
|
|
|
|
*/
|
2016-12-07 00:27:56 +00:00
|
|
|
processUpdate: function (file)
|
|
|
|
{
|
2016-12-07 04:43:02 +00:00
|
|
|
// This file has failed to load, so move it to the failed Set
|
2016-12-07 01:13:17 +00:00
|
|
|
if (file.state === CONST.FILE_ERRORED)
|
|
|
|
{
|
2016-12-12 22:35:47 +00:00
|
|
|
this.failed.set(file);
|
2016-12-07 04:43:02 +00:00
|
|
|
|
|
|
|
if (file.linkFile)
|
|
|
|
{
|
|
|
|
this.queue.delete(file.linkFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.removeFromQueue(file);
|
2016-12-07 01:13:17 +00:00
|
|
|
}
|
2016-12-07 04:43:02 +00:00
|
|
|
|
|
|
|
// If we got here, then the file loaded
|
|
|
|
|
|
|
|
// Special handling for multi-part files
|
|
|
|
|
|
|
|
if (file.linkFile)
|
2016-12-07 01:13:17 +00:00
|
|
|
{
|
2016-12-07 04:43:02 +00:00
|
|
|
if (file.state === CONST.FILE_COMPLETE && file.linkFile.state === CONST.FILE_COMPLETE)
|
|
|
|
{
|
|
|
|
// Partner has loaded, so add them both to Storage
|
2016-12-07 10:50:10 +00:00
|
|
|
|
2016-12-12 22:35:47 +00:00
|
|
|
this.storage.set({ type: file.linkType, fileA: file, fileB: file.linkFile });
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2016-12-07 04:43:02 +00:00
|
|
|
this.queue.delete(file.linkFile);
|
2016-12-07 01:13:17 +00:00
|
|
|
|
2016-12-07 04:43:02 +00:00
|
|
|
this.removeFromQueue(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-12-07 00:27:56 +00:00
|
|
|
{
|
2016-12-12 22:35:47 +00:00
|
|
|
this.storage.set(file);
|
2016-12-08 16:21:16 +00:00
|
|
|
|
2016-12-07 04:43:02 +00:00
|
|
|
this.removeFromQueue(file);
|
2016-12-07 00:27:56 +00:00
|
|
|
}
|
|
|
|
},
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#removeFromQueue
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Loader.File} file - [description]
|
|
|
|
*/
|
2016-12-08 16:21:16 +00:00
|
|
|
removeFromQueue: function (file)
|
|
|
|
{
|
|
|
|
this.queue.delete(file);
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING)
|
2016-12-08 16:21:16 +00:00
|
|
|
{
|
|
|
|
// We've processed all the files we loaded
|
|
|
|
this.processComplete();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#processComplete
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-12-07 00:27:56 +00:00
|
|
|
processComplete: function ()
|
|
|
|
{
|
2016-11-30 17:16:45 +00:00
|
|
|
this.list.clear();
|
|
|
|
this.inflight.clear();
|
|
|
|
this.queue.clear();
|
|
|
|
|
2017-08-04 17:43:05 +00:00
|
|
|
this.processCallback();
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_COMPLETE;
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-12 17:09:09 +00:00
|
|
|
this.emit('complete', this, this.storage.size, this.failed.size);
|
2018-01-24 14:26:17 +00:00
|
|
|
|
2018-02-12 13:37:07 +00:00
|
|
|
// Move to a User setting:
|
|
|
|
// this.removeAllListeners();
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* The Loader has finished.
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#processCallback
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-04 17:43:05 +00:00
|
|
|
processCallback: function ()
|
|
|
|
{
|
|
|
|
if (this.storage.size === 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The global Texture Manager
|
|
|
|
var cache = this.scene.sys.cache;
|
|
|
|
var textures = this.scene.sys.textures;
|
|
|
|
var anims = this.scene.sys.anims;
|
|
|
|
|
|
|
|
// Process multiatlas groups first
|
|
|
|
|
|
|
|
var file;
|
|
|
|
var fileA;
|
|
|
|
var fileB;
|
|
|
|
|
|
|
|
for (var key in this._multilist)
|
|
|
|
{
|
|
|
|
var data = [];
|
|
|
|
var images = [];
|
|
|
|
var keys = this._multilist[key];
|
|
|
|
|
|
|
|
for (var i = 0; i < keys.length; i++)
|
|
|
|
{
|
|
|
|
file = this.storage.get('key', keys[i]);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
if (file.type === 'image')
|
|
|
|
{
|
|
|
|
images.push(file.data);
|
|
|
|
}
|
|
|
|
else if (file.type === 'json')
|
|
|
|
{
|
|
|
|
data.push(file.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.storage.delete(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do we have everything needed?
|
|
|
|
if (images.length + data.length === keys.length)
|
|
|
|
{
|
|
|
|
// Yup, add them to the Texture Manager
|
|
|
|
|
|
|
|
// Is the data JSON Hash or JSON Array?
|
2018-02-27 13:48:45 +00:00
|
|
|
if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames))
|
2017-08-04 17:43:05 +00:00
|
|
|
{
|
|
|
|
textures.addAtlasJSONArray(key, images, data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textures.addAtlasJSONHash(key, images, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process all of the files
|
|
|
|
|
|
|
|
// Because AnimationJSON may require images to be loaded first, we process them last
|
|
|
|
var animJSON = [];
|
|
|
|
|
|
|
|
this.storage.each(function (file)
|
|
|
|
{
|
|
|
|
switch (file.type)
|
|
|
|
{
|
|
|
|
case 'animationJSON':
|
|
|
|
animJSON.push(file);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'image':
|
|
|
|
case 'svg':
|
|
|
|
case 'html':
|
|
|
|
textures.addImage(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'atlasjson':
|
|
|
|
|
|
|
|
fileA = file.fileA;
|
|
|
|
fileB = file.fileB;
|
|
|
|
|
|
|
|
if (fileA.type === 'image')
|
|
|
|
{
|
|
|
|
textures.addAtlas(fileA.key, fileA.data, fileB.data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textures.addAtlas(fileB.key, fileB.data, fileA.data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-01-29 23:38:27 +00:00
|
|
|
case 'dataimage':
|
|
|
|
|
|
|
|
fileA = file.fileA;
|
|
|
|
fileB = file.fileB;
|
|
|
|
|
|
|
|
if (fileA.linkParent)
|
|
|
|
{
|
|
|
|
textures.addImage(fileA.key, fileA.data, fileB.data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textures.addImage(fileB.key, fileB.data, fileA.data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-08-10 04:17:02 +00:00
|
|
|
case 'unityatlas':
|
|
|
|
|
|
|
|
fileA = file.fileA;
|
|
|
|
fileB = file.fileB;
|
|
|
|
|
|
|
|
if (fileA.type === 'image')
|
|
|
|
{
|
|
|
|
textures.addUnityAtlas(fileA.key, fileA.data, fileB.data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textures.addUnityAtlas(fileB.key, fileB.data, fileA.data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-08-04 17:43:05 +00:00
|
|
|
case 'bitmapfont':
|
|
|
|
|
|
|
|
fileA = file.fileA;
|
|
|
|
fileB = file.fileB;
|
|
|
|
|
|
|
|
if (fileA.type === 'image')
|
|
|
|
{
|
|
|
|
cache.bitmapFont.add(fileB.key, { data: ParseXMLBitmapFont(fileB.data), texture: fileA.key, frame: null });
|
|
|
|
textures.addImage(fileA.key, fileA.data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cache.bitmapFont.add(fileA.key, { data: ParseXMLBitmapFont(fileA.data), texture: fileB.key, frame: null });
|
|
|
|
textures.addImage(fileB.key, fileB.data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'spritesheet':
|
|
|
|
textures.addSpriteSheet(file.key, file.data, file.config);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'json':
|
|
|
|
cache.json.add(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'xml':
|
|
|
|
cache.xml.add(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'text':
|
|
|
|
cache.text.add(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
2017-12-07 02:18:40 +00:00
|
|
|
case 'obj':
|
|
|
|
cache.obj.add(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
2017-08-04 17:43:05 +00:00
|
|
|
case 'binary':
|
|
|
|
cache.binary.add(file.key, file.data);
|
|
|
|
break;
|
|
|
|
|
2017-11-10 17:51:19 +00:00
|
|
|
case 'audio':
|
|
|
|
cache.audio.add(file.key, file.data);
|
2017-08-04 17:43:05 +00:00
|
|
|
break;
|
|
|
|
|
2017-11-30 17:09:11 +00:00
|
|
|
case 'audioSprite':
|
|
|
|
|
|
|
|
var files = [ file.fileA, file.fileB ];
|
|
|
|
|
|
|
|
files.forEach(function (file)
|
|
|
|
{
|
|
|
|
cache[file.type].add(file.key, file.data);
|
|
|
|
});
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2017-08-04 17:43:05 +00:00
|
|
|
case 'glsl':
|
|
|
|
cache.shader.add(file.key, file.data);
|
|
|
|
break;
|
2017-11-09 18:21:06 +00:00
|
|
|
|
|
|
|
case 'tilemapCSV':
|
|
|
|
case 'tilemapJSON':
|
2018-01-18 00:30:22 +00:00
|
|
|
cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data });
|
2017-11-09 18:21:06 +00:00
|
|
|
break;
|
2017-08-04 17:43:05 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
animJSON.forEach(function (file)
|
|
|
|
{
|
|
|
|
anims.fromJSON(file.data);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.storage.clear();
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#saveJSON
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-20 16:15:49 +00:00
|
|
|
* @param {*} data - [description]
|
2018-03-19 00:54:19 +00:00
|
|
|
* @param {string} [filename=file.json] - [description]
|
2018-02-09 17:56:43 +00:00
|
|
|
*
|
2018-03-19 00:54:19 +00:00
|
|
|
* @return {Phaser.Loader.LoaderPlugin} This Loader plugin.
|
2018-02-09 17:56:43 +00:00
|
|
|
*/
|
2017-10-02 21:41:52 +00:00
|
|
|
saveJSON: function (data, filename)
|
|
|
|
{
|
|
|
|
return this.save(JSON.stringify(data), filename);
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#save
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-20 16:15:49 +00:00
|
|
|
* @param {*} data - [description]
|
2018-03-19 00:54:19 +00:00
|
|
|
* @param {string} [filename=file.json] - [description]
|
|
|
|
* @param {string} [filetype=application/json] - [description]
|
2018-02-09 17:56:43 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.LoaderPlugin} This Loader plugin.
|
|
|
|
*/
|
2017-10-02 21:41:52 +00:00
|
|
|
save: function (data, filename, filetype)
|
|
|
|
{
|
|
|
|
if (filename === undefined) { filename = 'file.json'; }
|
|
|
|
if (filetype === undefined) { filetype = 'application/json'; }
|
|
|
|
|
2018-01-19 14:54:50 +00:00
|
|
|
var blob = new Blob([ data ], { type: filetype });
|
2017-10-02 21:41:52 +00:00
|
|
|
|
|
|
|
var url = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
var a = document.createElement('a');
|
|
|
|
|
|
|
|
a.download = filename;
|
|
|
|
a.textContent = 'Download ' + filename;
|
|
|
|
a.href = url;
|
|
|
|
a.click();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#reset
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
reset: function ()
|
|
|
|
{
|
|
|
|
this.list.clear();
|
|
|
|
this.inflight.clear();
|
|
|
|
this.failed.clear();
|
|
|
|
this.queue.clear();
|
|
|
|
this.storage.clear();
|
|
|
|
|
2018-01-19 17:07:38 +00:00
|
|
|
var gameConfig = this.systems.game.config;
|
|
|
|
var sceneConfig = this.systems.settings.loader;
|
|
|
|
|
2018-01-19 17:10:23 +00:00
|
|
|
this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL));
|
2018-01-19 17:07:38 +00:00
|
|
|
this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath));
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_IDLE;
|
2016-11-30 17:16:45 +00:00
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#loadArray
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-22 12:51:30 +00:00
|
|
|
* @param {LoaderFileObject[]} files - [description]
|
2018-02-09 17:56:43 +00:00
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2018-01-19 19:13:27 +00:00
|
|
|
loadArray: function (files)
|
|
|
|
{
|
|
|
|
if (Array.isArray(files))
|
|
|
|
{
|
|
|
|
for (var i = 0; i < files.length; i++)
|
|
|
|
{
|
|
|
|
this.file(files[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (this.list.size > 0);
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#file
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-22 12:51:30 +00:00
|
|
|
* @param {LoaderFileObject} file - [description]
|
2018-02-09 17:56:43 +00:00
|
|
|
*
|
|
|
|
* @return {Phaser.Loader.File} [description]
|
|
|
|
*/
|
2018-01-19 19:13:27 +00:00
|
|
|
file: function (file)
|
|
|
|
{
|
|
|
|
var entry;
|
|
|
|
var key = file.key;
|
|
|
|
|
|
|
|
switch (file.type)
|
|
|
|
{
|
|
|
|
case 'spritesheet':
|
|
|
|
entry = this.spritesheet(key, file.url, file.config, file.xhrSettings);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'atlas':
|
|
|
|
entry = this.atlas(key, file.textureURL, file.atlasURL, file.textureXhrSettings, file.atlasXhrSettings);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bitmapFont':
|
|
|
|
entry = this.bitmapFont(key, file.textureURL, file.xmlURL, file.textureXhrSettings, file.xmlXhrSettings);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'multiatlas':
|
|
|
|
entry = this.multiatlas(key, file.textureURLs, file.atlasURLs, file.textureXhrSettings, file.atlasXhrSettings);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'audioSprite':
|
|
|
|
entry = this.audioSprite(key, file.urls, file.json, file.config, file.audioXhrSettings, file.jsonXhrSettings);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// image, json, xml, binary, text, glsl, svg, obj
|
|
|
|
default:
|
|
|
|
entry = this[file.type](key, file.url, file.xhrSettings);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#shutdown
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-19 14:54:50 +00:00
|
|
|
shutdown: function ()
|
|
|
|
{
|
|
|
|
this.reset();
|
|
|
|
this.state = CONST.LOADER_SHUTDOWN;
|
|
|
|
},
|
|
|
|
|
2018-02-09 17:56:43 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Loader.LoaderPlugin#destroy
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2016-11-30 17:16:45 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
|
|
|
this.reset();
|
2017-07-14 13:30:20 +00:00
|
|
|
this.state = CONST.LOADER_DESTROYED;
|
2016-11-30 17:16:45 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 15:05:22 +00:00
|
|
|
});
|
2016-11-30 17:16:45 +00:00
|
|
|
|
2018-01-19 14:54:50 +00:00
|
|
|
PluginManager.register('Loader', LoaderPlugin, 'load');
|
2018-01-19 14:47:16 +00:00
|
|
|
|
2018-01-19 14:54:50 +00:00
|
|
|
module.exports = LoaderPlugin;
|