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-09 01:30:10 +00:00
|
|
|
var Class = require('../utils/Class');
|
2018-05-11 00:50:37 +00:00
|
|
|
var EventEmitter = require('eventemitter3');
|
|
|
|
var GetFastValue = require('../utils/object/GetFastValue');
|
2018-01-16 02:08:04 +00:00
|
|
|
|
2018-05-10 16:14:33 +00:00
|
|
|
// Contains the plugins that Phaser uses globally and locally.
|
|
|
|
// These are the source objects, not instantiated.
|
2018-05-11 00:50:37 +00:00
|
|
|
var corePlugins = {};
|
|
|
|
|
|
|
|
// Contains the plugins that the dev has loaded into their game
|
2018-05-11 15:01:37 +00:00
|
|
|
// These are the source objects, not instantiated.
|
2018-05-11 13:06:51 +00:00
|
|
|
var gamePlugins = {};
|
2018-01-09 01:30:10 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* The PluginManager is global and belongs to the Game instance, not a Scene.
|
|
|
|
* It handles the installation and removal of all global and Scene based plugins.
|
|
|
|
* Plugins automatically register themselves with the PluginManager in their respective classes.
|
|
|
|
*
|
|
|
|
* @class PluginManager
|
2018-05-10 16:14:33 +00:00
|
|
|
* @memberOf Phaser.Plugins
|
2018-02-12 23:13:16 +00:00
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Game} game - [description]
|
|
|
|
*/
|
2018-01-09 01:30:10 +00:00
|
|
|
var PluginManager = new Class({
|
|
|
|
|
2018-05-11 00:50:37 +00:00
|
|
|
Extends: EventEmitter,
|
|
|
|
|
2018-01-09 01:30:10 +00:00
|
|
|
initialize:
|
|
|
|
|
2018-01-18 13:59:32 +00:00
|
|
|
function PluginManager (game)
|
2018-01-09 01:30:10 +00:00
|
|
|
{
|
2018-05-11 00:50:37 +00:00
|
|
|
EventEmitter.call(this);
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @name Phaser.Plugins.PluginManager#game
|
2018-02-12 23:13:16 +00:00
|
|
|
* @type {Phaser.Game}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
this.game = game;
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-11 00:50:37 +00:00
|
|
|
// Plugins currently running and managed by this Plugin Manager.
|
|
|
|
// These are Game instance specific.
|
2018-05-11 13:06:51 +00:00
|
|
|
// {
|
|
|
|
// key: '' <- the key set by the game, not the plugin author
|
|
|
|
// plugin: instance <- an instance of the plugin
|
|
|
|
// active: bool <- considered 'active' or not?
|
|
|
|
// }
|
2018-05-11 15:01:37 +00:00
|
|
|
this.plugins = [];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
// A list of plugin keys that should be installed into Scenes as well as the Core Plugins
|
2018-05-11 00:50:37 +00:00
|
|
|
this.scenePlugins = [];
|
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
this._pendingGlobal = [];
|
|
|
|
this._pendingScene = [];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-10 16:14:33 +00:00
|
|
|
if (game.isBooted)
|
|
|
|
{
|
|
|
|
this.boot();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
game.events.once('boot', this.boot, this);
|
|
|
|
}
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#boot
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
boot: function ()
|
|
|
|
{
|
2018-05-11 15:01:37 +00:00
|
|
|
var i;
|
2018-05-11 17:55:44 +00:00
|
|
|
var entry;
|
|
|
|
var key;
|
|
|
|
var plugin;
|
|
|
|
var start;
|
|
|
|
var mapping;
|
2018-05-11 15:01:37 +00:00
|
|
|
var config = this.game.config;
|
2018-05-10 16:14:33 +00:00
|
|
|
|
|
|
|
// Any plugins to install?
|
2018-05-11 15:01:37 +00:00
|
|
|
var list = config.installGlobalPlugins;
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
// Any plugins added outside of the game config, but before the game booted?
|
2018-05-11 15:01:37 +00:00
|
|
|
list = list.concat(this._pendingGlobal);
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
for (i = 0; i < list.length; i++)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 17:55:44 +00:00
|
|
|
entry = list[i];
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
// { key: 'TestPlugin', plugin: TestPlugin, start: true }
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 17:55:44 +00:00
|
|
|
key = GetFastValue(entry, 'key', null);
|
|
|
|
plugin = GetFastValue(entry, 'plugin', null);
|
|
|
|
start = GetFastValue(entry, 'start', false);
|
2018-05-11 13:06:51 +00:00
|
|
|
|
|
|
|
if (key && plugin)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 15:01:37 +00:00
|
|
|
this.install(key, plugin, start);
|
2018-05-10 16:14:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-11 13:06:51 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
// Any scene plugins to install?
|
|
|
|
list = config.installScenePlugins;
|
|
|
|
|
|
|
|
// Any plugins added outside of the game config, but before the game booted?
|
|
|
|
list = list.concat(this._pendingScene);
|
|
|
|
|
|
|
|
for (i = 0; i < list.length; i++)
|
|
|
|
{
|
2018-05-11 17:55:44 +00:00
|
|
|
entry = list[i];
|
2018-05-11 15:01:37 +00:00
|
|
|
|
|
|
|
// { key: 'moveSpritePlugin', plugin: MoveSpritePlugin, , mapping: 'move' }
|
|
|
|
|
2018-05-11 17:55:44 +00:00
|
|
|
key = GetFastValue(entry, 'key', null);
|
|
|
|
plugin = GetFastValue(entry, 'plugin', null);
|
|
|
|
mapping = GetFastValue(entry, 'mapping', null);
|
2018-05-11 15:01:37 +00:00
|
|
|
|
|
|
|
if (key && plugin)
|
|
|
|
{
|
|
|
|
this.installScenePlugin(key, plugin, mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._pendingGlobal = [];
|
|
|
|
this._pendingScene = [];
|
|
|
|
|
|
|
|
this.game.events.once('destroy', this.destroy, this);
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
2018-01-09 01:30:10 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#installGlobal
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scenes.Systems} sys - [description]
|
|
|
|
* @param {array} globalPlugins - [description]
|
|
|
|
*/
|
2018-01-18 05:21:14 +00:00
|
|
|
installGlobal: function (sys, globalPlugins)
|
2018-01-16 02:08:04 +00:00
|
|
|
{
|
2018-05-11 00:50:37 +00:00
|
|
|
var game = this.game;
|
2018-01-18 05:21:14 +00:00
|
|
|
var scene = sys.scene;
|
|
|
|
var map = sys.settings.map;
|
2018-01-16 02:08:04 +00:00
|
|
|
|
2018-01-18 05:21:14 +00:00
|
|
|
// Reference the GlobalPlugins from Game into Scene.Systems
|
2018-01-16 22:28:29 +00:00
|
|
|
for (var i = 0; i < globalPlugins.length; i++)
|
2018-01-16 02:08:04 +00:00
|
|
|
{
|
2018-01-18 05:21:14 +00:00
|
|
|
var pluginKey = globalPlugins[i];
|
|
|
|
|
|
|
|
// console.log('PluginManager.global', pluginKey);
|
2018-01-16 02:08:04 +00:00
|
|
|
|
2018-01-30 13:15:50 +00:00
|
|
|
if (game[pluginKey])
|
2018-01-18 05:21:14 +00:00
|
|
|
{
|
2018-01-30 13:15:50 +00:00
|
|
|
sys[pluginKey] = game[pluginKey];
|
|
|
|
|
|
|
|
// Scene level injection
|
|
|
|
if (map.hasOwnProperty(pluginKey))
|
|
|
|
{
|
|
|
|
scene[map[pluginKey]] = sys[pluginKey];
|
|
|
|
}
|
2018-01-18 05:21:14 +00:00
|
|
|
}
|
2018-01-16 22:28:29 +00:00
|
|
|
}
|
2018-01-18 05:21:14 +00:00
|
|
|
},
|
2018-01-16 22:28:29 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#installLocal
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Scenes.Systems} sys - [description]
|
|
|
|
* @param {array} scenePlugins - [description]
|
|
|
|
*/
|
2018-01-18 05:21:14 +00:00
|
|
|
installLocal: function (sys, scenePlugins)
|
|
|
|
{
|
|
|
|
var scene = sys.scene;
|
|
|
|
var map = sys.settings.map;
|
2018-01-18 13:59:32 +00:00
|
|
|
var isBooted = sys.settings.isBooted;
|
2018-01-18 05:21:14 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < scenePlugins.length; i++)
|
2018-01-16 22:28:29 +00:00
|
|
|
{
|
2018-01-18 05:21:14 +00:00
|
|
|
var pluginKey = scenePlugins[i];
|
|
|
|
|
2018-05-11 00:50:37 +00:00
|
|
|
if (!corePlugins[pluginKey])
|
2018-01-30 13:15:50 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-05-11 00:50:37 +00:00
|
|
|
var source = corePlugins[pluginKey];
|
2018-01-18 05:21:14 +00:00
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
var plugin = new source.plugin(scene, this);
|
2018-01-16 22:28:29 +00:00
|
|
|
|
2018-01-18 13:59:32 +00:00
|
|
|
sys[source.mapping] = plugin;
|
2018-01-17 03:41:58 +00:00
|
|
|
|
2018-01-18 05:21:14 +00:00
|
|
|
// Scene level injection
|
2018-05-11 15:01:37 +00:00
|
|
|
if (source.custom)
|
|
|
|
{
|
|
|
|
scene[source.mapping] = plugin;
|
|
|
|
}
|
|
|
|
else if (map.hasOwnProperty(source.mapping))
|
2018-01-18 05:21:14 +00:00
|
|
|
{
|
2018-01-18 13:59:32 +00:00
|
|
|
scene[map[source.mapping]] = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scene is already booted, usually because this method is being called at run-time, so boot the plugin
|
|
|
|
if (isBooted)
|
|
|
|
{
|
|
|
|
plugin.boot();
|
2018-01-16 02:08:04 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-09 01:30:10 +00:00
|
|
|
},
|
|
|
|
|
2018-05-11 15:01:37 +00:00
|
|
|
// Called by Scene.Systems to get the default list of plugins to install
|
|
|
|
getDefaultScenePlugins: function ()
|
|
|
|
{
|
|
|
|
var list = this.game.config.defaultPlugins;
|
|
|
|
|
|
|
|
// Merge in custom Scene plugins
|
|
|
|
list = list.concat(this.scenePlugins);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
|
|
|
// private to the PM
|
|
|
|
// key = Scene.Systems property key
|
|
|
|
// plugin = code
|
|
|
|
// mapping = Scene key
|
2018-05-11 17:22:28 +00:00
|
|
|
installScenePlugin: function (key, plugin, mapping, addToScene)
|
2018-05-11 15:01:37 +00:00
|
|
|
{
|
|
|
|
if (typeof plugin !== 'function')
|
|
|
|
{
|
|
|
|
console.warn('Invalid Scene Plugin: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (corePlugins.hasOwnProperty(key))
|
|
|
|
{
|
|
|
|
console.warn('Scene Plugin key in use: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add it to the plugin store
|
|
|
|
corePlugins[key] = { plugin: plugin, mapping: mapping, custom: true };
|
|
|
|
|
|
|
|
this.scenePlugins.push(key);
|
2018-05-11 17:22:28 +00:00
|
|
|
|
|
|
|
if (addToScene)
|
|
|
|
{
|
|
|
|
var instance = new plugin(addToScene, this);
|
|
|
|
|
|
|
|
addToScene.sys[key] = instance;
|
|
|
|
|
|
|
|
if (mapping && mapping !== '')
|
|
|
|
{
|
|
|
|
addToScene[mapping] = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance.boot();
|
|
|
|
}
|
2018-05-11 15:01:37 +00:00
|
|
|
},
|
|
|
|
|
2018-05-10 16:14:33 +00:00
|
|
|
/**
|
2018-05-11 15:01:37 +00:00
|
|
|
* Installs a global plugin into the PluginManager.
|
|
|
|
* Global plugins belong to the game and cannot be installed into a Scene.
|
|
|
|
* For Scene level plugins, see `installScenePlugin`.
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-11 00:50:37 +00:00
|
|
|
* Key is a reference used to get the plugin from the plugins object (i.e. MyPlugin)
|
|
|
|
* Plugin is the function to instantiate to create a plugin instance.
|
2018-05-10 16:14:33 +00:00
|
|
|
*
|
2018-05-11 13:06:51 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#install
|
2018-05-10 16:14:33 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - [description]
|
2018-05-11 00:50:37 +00:00
|
|
|
* @param {function} plugin - [description]
|
2018-05-10 16:14:33 +00:00
|
|
|
*/
|
2018-05-11 15:01:37 +00:00
|
|
|
install: function (key, plugin, start)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 00:50:37 +00:00
|
|
|
if (start === undefined) { start = false; }
|
|
|
|
|
|
|
|
if (typeof plugin !== 'function')
|
|
|
|
{
|
|
|
|
console.warn('Invalid Plugin: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (gamePlugins.hasOwnProperty(key))
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
|
|
|
console.warn('Plugin key in use: ' + key);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (!this.game.isBooted)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-05-11 15:01:37 +00:00
|
|
|
this._pendingGlobal.push({ key: key, plugin: plugin, start: start });
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
2018-05-11 13:06:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add it to the plugin store
|
|
|
|
gamePlugins[key] = plugin;
|
2018-05-11 00:50:37 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (start)
|
|
|
|
{
|
|
|
|
return this.start(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getIndex: function (key)
|
|
|
|
{
|
|
|
|
var list = this.plugins;
|
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
var entry = list[i];
|
2018-05-11 00:50:37 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
if (entry.key === key)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
getEntry: function (key)
|
|
|
|
{
|
|
|
|
var idx = this.getIndex(key);
|
|
|
|
|
|
|
|
if (idx !== -1)
|
|
|
|
{
|
|
|
|
return this.plugins[idx];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isActive: function (key)
|
|
|
|
{
|
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
return (entry && entry.active);
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
start: function (key, runAs)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
if (runAs === undefined) { runAs = key; }
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
var entry = this.getEntry(runAs);
|
|
|
|
|
|
|
|
// Plugin already running under this key?
|
|
|
|
if (entry && !entry.active)
|
|
|
|
{
|
|
|
|
// It exists, we just need to start it up again
|
|
|
|
entry.active = true;
|
|
|
|
entry.plugin.start();
|
|
|
|
}
|
|
|
|
else if (!entry)
|
2018-05-11 00:50:37 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
var plugin = this.getClass(key);
|
|
|
|
|
|
|
|
if (plugin)
|
|
|
|
{
|
|
|
|
var instance = new plugin(this);
|
|
|
|
|
|
|
|
entry = {
|
|
|
|
key: runAs,
|
|
|
|
plugin: instance,
|
|
|
|
active: true
|
|
|
|
};
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
this.plugins.push(entry);
|
|
|
|
|
|
|
|
instance.init();
|
|
|
|
instance.start();
|
|
|
|
}
|
2018-05-11 00:50:37 +00:00
|
|
|
}
|
2018-05-10 16:14:33 +00:00
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
return (entry) ? entry.plugin : null;
|
|
|
|
},
|
|
|
|
|
|
|
|
stop: function (key)
|
|
|
|
{
|
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
if (entry && entry.active)
|
|
|
|
{
|
|
|
|
entry.active = false;
|
|
|
|
entry.plugin.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
get: function (key)
|
|
|
|
{
|
|
|
|
var entry = this.getEntry(key);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
return entry.plugin;
|
|
|
|
}
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-11 13:06:51 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#getClass
|
2018-05-10 16:14:33 +00:00
|
|
|
* @since 3.8.0
|
|
|
|
*
|
|
|
|
* @param {string} key - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.Plugins.Plugin} A Plugin object
|
|
|
|
*/
|
2018-05-11 13:06:51 +00:00
|
|
|
getClass: function (key)
|
2018-05-10 16:14:33 +00:00
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
return (gamePlugins.hasOwnProperty(key)) ? gamePlugins[key] : null;
|
2018-05-10 16:14:33 +00:00
|
|
|
},
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#remove
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} key - [description]
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
remove: function (key)
|
|
|
|
{
|
2018-05-11 13:06:51 +00:00
|
|
|
delete gamePlugins[key];
|
2018-01-16 02:08:04 +00:00
|
|
|
},
|
2018-01-09 01:30:10 +00:00
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager#destroy
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2018-01-16 02:08:04 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2018-01-31 03:38:10 +00:00
|
|
|
this.game = null;
|
2018-01-16 02:08:04 +00:00
|
|
|
}
|
2018-01-09 01:30:10 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-05-11 13:06:51 +00:00
|
|
|
/*
|
|
|
|
* "Sometimes, the elegant implementation is just a function.
|
|
|
|
* Not a method. Not a class. Not a framework. Just a function."
|
|
|
|
* -- John Carmack
|
|
|
|
*/
|
|
|
|
|
2018-02-12 23:13:16 +00:00
|
|
|
/**
|
2018-05-11 00:50:37 +00:00
|
|
|
* Static method called directly by the Core internal Plugins.
|
2018-02-12 23:13:16 +00:00
|
|
|
* Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin)
|
|
|
|
* Plugin is the object to instantiate to create the plugin
|
|
|
|
* Mapping is what the plugin is injected into the Scene.Systems as (i.e. input)
|
|
|
|
*
|
2018-05-10 16:14:33 +00:00
|
|
|
* @method Phaser.Plugins.PluginManager.register
|
2018-02-12 23:13:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string} key - [description]
|
|
|
|
* @param {object} plugin - [description]
|
|
|
|
* @param {string} mapping - [description]
|
|
|
|
*/
|
2018-01-18 05:21:14 +00:00
|
|
|
PluginManager.register = function (key, plugin, mapping)
|
2018-01-16 02:08:04 +00:00
|
|
|
{
|
2018-05-11 15:01:37 +00:00
|
|
|
corePlugins[key] = { plugin: plugin, mapping: mapping, custom: false };
|
2018-01-16 02:08:04 +00:00
|
|
|
};
|
2018-01-09 01:30:10 +00:00
|
|
|
|
|
|
|
module.exports = PluginManager;
|