Phaser API Documentation

  Version: 
install(key, plugin, [start], [mapping], [data])

Description:

Installs a new Global Plugin into the Plugin Manager and optionally starts it running. A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed and used by all Scenes in your game.

The key property is what you use to access this plugin from the Plugin Manager.

this.plugins.install('powerupsPlugin', pluginCode);

// and from within the scene:
this.plugins.get('powerupsPlugin');

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.

The same plugin can be installed multiple times into the Plugin Manager by simply giving each instance its own unique key.

Parameters:

name type arguments Default description
key string

The unique handle given to this plugin within the Plugin Manager.

plugin function

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

start boolean <optional> false

Automatically start the plugin running? This is always true if you provide a mapping value.

mapping string <optional>

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

data any <optional>

A value passed to the plugin's init method.

Returns:
Description:

The plugin that was started, or null if start was false, or game isn't yet booted.

Since: 3.8.0