Phaser API Documentation

  Version: 
installScenePlugin(key, plugin, [mapping], [addToScene], [fromLoader])

Description:

Installs a new Scene Plugin into the Plugin Manager and optionally adds it to the given Scene as well. A Scene Plugin added to the manager in this way will be automatically installed into all new Scenes using the key and mapping given.

The key property is what the plugin is injected into Scene.Systems as. The mapping property is optional, and if specified is what the plugin is installed into the Scene as. For example:

this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups');

// and from within the scene:
this.sys.powerupsPlugin; // key value
this.powerups; // mapping value

This method is called automatically by Phaser if you install your plugins using either the Game Configuration object, or by preloading them via the Loader.

Parameters:

name type arguments Default description
key string

The property key that will be used to add this plugin to Scene.Systems.

plugin function

The plugin code. This should be the non-instantiated version.

mapping string <optional>

If this plugin is injected into the Phaser.Scene class, this is the property key to use.

addToScene Phaser.Scene <optional>

Optionally automatically add this plugin to the given Scene.

fromLoader boolean <optional> false

Is this being called by the Loader?

Since: 3.8.0