Class: BasePlugin

Phaser.Plugins. BasePlugin

A Global Plugin is installed just once into the Game owned Plugin Manager.
It can listen for Game events and respond to them.


new BasePlugin(pluginManager)

Parameters:
Name Type Description
pluginManager Phaser.Plugins.PluginManager

A reference to the Plugin Manager.

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 9)

Members


<protected> game :Phaser.Game

A reference to the Game instance this plugin is running under.

Type:
Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 38)

<protected> pluginManager :Phaser.Plugins.PluginManager

A handy reference to the Plugin Manager that is responsible for this plugin.
Can be used as a route to gain access to game systems and events.

Type:
Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 27)

<protected, nullable> scene :Phaser.Scene

A reference to the Scene that has installed this plugin.
Only set if it's a Scene Plugin, otherwise null.
This property is only set when the plugin is instantiated and added to the Scene, not before.
You cannot use it during the init method, but you can during the boot method.

Type:
Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 48)

<protected, nullable> systems :Phaser.Scenes.Systems

A reference to the Scene Systems of the Scene that has installed this plugin.
Only set if it's a Scene Plugin, otherwise null.
This property is only set when the plugin is instantiated and added to the Scene, not before.
You cannot use it during the init method, but you can during the boot method.

Type:
Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 61)

Methods


boot()

If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots.
By this point the plugin properties scene and systems will have already been set.
In here you can listen for Scene events and set-up whatever you need for this plugin to run.

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 130)

destroy()

Game instance has been destroyed.
You must release everything in here, all references, all objects, free it all up.

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 158)

init( [data])

Called by the PluginManager when this plugin is first instantiated.
It will never be called again on this instance.
In here you can set-up whatever you need for this plugin to run.
If a plugin is set to automatically start then BasePlugin.start will be called immediately after this.

Parameters:
Name Type Argument Description
data any <optional>
<nullable>

A value specified by the user, if any, from the data property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's install method (if started manually).

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 75)

start()

Called by the PluginManager when this plugin is started.
If a plugin is stopped, and then started again, this will get called again.
Typically called immediately after BasePlugin.init.

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 90)

stop()

Called by the PluginManager when this plugin is stopped.
The game code has requested that your plugin stop doing whatever it does.
It is now considered as 'inactive' by the PluginManager.
Handle that process here (i.e. stop listening for events, etc)
If the plugin is started again then BasePlugin.start will be called again.

Since: 3.8.0
Source: src/plugins/BasePlugin.js (Line 116)