How to create muliple instances of custom plugien?

18 views
Skip to first unread message

Pin-Hua Tien

unread,
Feb 6, 2018, 1:57:49 AM2/6/18
to Phaser 3 Development
In plugin template, it uses

PluginManager.register('BasePlugin', BasePlugin, 'base');

to register the key and reference of that plugin.
The 3rd parameter 'base' is the
"Mapping is what the plugin is injected into the Scene.Systems as (i.e. input)".
It only create 1 instance of 'BasePlugin' in scene.system by "install" function (or PluginManager.installGlobal, PluginManager.installLocal)

this.sys.install('BasePlugin');


How to create muliple instances of custom plugien?
Maybe add a function in
PluginManager, to create plugin instance by pluginKey.

var source = plugins[pluginKey];
var inst = new source.plugin(scene); // return inst

(copy from PluginManager.installLocal)

Reply all
Reply to author
Forward
0 new messages