mirror of
https://github.com/photonstorm/phaser
synced 2025-03-01 05:47:28 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f019b8ad75
4 changed files with 91 additions and 7 deletions
|
@ -204,7 +204,7 @@ File.createObjectURL = function (image, blob, defaultType)
|
|||
*/
|
||||
File.revokeObjectURL = function (image)
|
||||
{
|
||||
if(URL)
|
||||
if (typeof URL === 'function')
|
||||
{
|
||||
URL.revokeObjectURL(image.src);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ var GLSLFile = require('./filetypes/GLSLFile');
|
|||
var HTMLFile = require('./filetypes/HTMLFile');
|
||||
var ImageFile = require('./filetypes/ImageFile');
|
||||
var JSONFile = require('./filetypes/JSONFile');
|
||||
var PluginFile = require('./filetypes/PluginFile');
|
||||
var ScriptFile = require('./filetypes/ScriptFile');
|
||||
var SpriteSheet = require('./filetypes/SpriteSheet');
|
||||
var SVGFile = require('./filetypes/SVGFile');
|
||||
|
@ -75,6 +76,11 @@ var Loader = new Class({
|
|||
return ScriptFile.create(this, key, url, xhrSettings);
|
||||
},
|
||||
|
||||
plugin: function (key, url, xhrSettings)
|
||||
{
|
||||
return PluginFile.create(this, key, url, xhrSettings);
|
||||
},
|
||||
|
||||
xml: function (key, url, xhrSettings)
|
||||
{
|
||||
return XMLFile.create(this, key, url, xhrSettings);
|
||||
|
@ -321,7 +327,7 @@ var Loader = new Class({
|
|||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
});
|
||||
|
|
73
src/loader/filetypes/PluginFile.js
Normal file
73
src/loader/filetypes/PluginFile.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var CONST = require('../const');
|
||||
var File = require('../File');
|
||||
var GetFastValue = require('../../utils/object/GetFastValue');
|
||||
var PluginManager = require('../../plugins/PluginManager');
|
||||
|
||||
// Phaser.Loader.FileTypes.PluginFile
|
||||
|
||||
var PluginFile = new Class({
|
||||
|
||||
Extends: File,
|
||||
|
||||
initialize:
|
||||
|
||||
function PluginFile (key, url, path, xhrSettings)
|
||||
{
|
||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||
|
||||
var fileConfig = {
|
||||
type: 'script',
|
||||
extension: GetFastValue(key, 'extension', 'js'),
|
||||
responseType: 'text',
|
||||
key: fileKey,
|
||||
url: GetFastValue(key, 'file', url),
|
||||
path: path,
|
||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||
};
|
||||
|
||||
File.call(this, fileConfig);
|
||||
},
|
||||
|
||||
onProcess: function (callback)
|
||||
{
|
||||
this.state = CONST.FILE_PROCESSING;
|
||||
|
||||
this.data = document.createElement('script');
|
||||
this.data.language = 'javascript';
|
||||
this.data.type = 'text/javascript';
|
||||
this.data.defer = false;
|
||||
this.data.text = this.xhrLoader.responseText;
|
||||
|
||||
document.head.appendChild(this.data);
|
||||
|
||||
// Need to wait for onload?
|
||||
window[this.key].register(PluginManager);
|
||||
|
||||
this.onComplete();
|
||||
|
||||
callback(this);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
PluginFile.create = function (loader, key, url, xhrSettings)
|
||||
{
|
||||
if (Array.isArray(key))
|
||||
{
|
||||
for (var i = 0; i < key.length; i++)
|
||||
{
|
||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||
loader.addFile(new PluginFile(key[i], url, loader.path, xhrSettings));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loader.addFile(new PluginFile(key, url, loader.path, xhrSettings));
|
||||
}
|
||||
|
||||
// For method chaining
|
||||
return loader;
|
||||
};
|
||||
|
||||
module.exports = PluginFile;
|
|
@ -28,6 +28,7 @@ var Systems = new Class({
|
|||
|
||||
this.anims;
|
||||
this.cache;
|
||||
this.plugins;
|
||||
this.registry;
|
||||
this.sound;
|
||||
this.textures;
|
||||
|
@ -47,13 +48,17 @@ var Systems = new Class({
|
|||
{
|
||||
this.game = game;
|
||||
|
||||
game.plugins.installGlobal(this, GlobalPlugins);
|
||||
var pluginManager = game.plugins;
|
||||
|
||||
game.plugins.installLocal(this, CoreScenePlugins);
|
||||
this.plugins = pluginManager;
|
||||
|
||||
game.plugins.installLocal(this, GetScenePlugins(this));
|
||||
pluginManager.installGlobal(this, GlobalPlugins);
|
||||
|
||||
game.plugins.installLocal(this, GetPhysicsPlugins(this));
|
||||
pluginManager.installLocal(this, CoreScenePlugins);
|
||||
|
||||
pluginManager.installLocal(this, GetScenePlugins(this));
|
||||
|
||||
pluginManager.installLocal(this, GetPhysicsPlugins(this));
|
||||
|
||||
this.events.emit('boot', this);
|
||||
|
||||
|
@ -67,7 +72,7 @@ var Systems = new Class({
|
|||
plugin = [ plugin ];
|
||||
}
|
||||
|
||||
this.game.plugins.installLocal(this, plugin);
|
||||
this.plugins.installLocal(this, plugin);
|
||||
},
|
||||
|
||||
step: function (time, delta)
|
||||
|
|
Loading…
Add table
Reference in a new issue