Skip to main content
Version: Phaser v4.0.0

LightsPlugin

A Scene plugin that provides a Phaser.GameObjects.LightsManager for rendering objects with dynamic lighting.

Available from within a Scene via this.lights.

Add Lights using the Phaser.GameObjects.LightsManager#addLight method:


// Enable the Lights Manager because it is disabled by default

this.lights.enable();



// Create a Light at [400, 300] with a radius of 200

this.lights.addLight(400, 300, 200);

For Game Objects to be affected by the Lights when rendered, you will need to set them to use lighting like so:


sprite.setLighting(true);

Constructor

new LightsPlugin(scene)

Parameters

nametypeoptionaldescription
scenePhaser.SceneNoThe Scene that this Lights Plugin belongs to.

Scope: static

Extends

Phaser.GameObjects.LightsManager

Source: src/gameobjects/lights/LightsPlugin.js#L12
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.LightsManager:


Public Members

scene

scene: Phaser.Scene

Description:

A reference to the Scene that this Lights Plugin belongs to.

Source: src/gameobjects/lights/LightsPlugin.js#L50
Since: 3.0.0


systems

systems: Phaser.Scenes.Systems

Description:

A reference to the Scene's systems.

Source: src/gameobjects/lights/LightsPlugin.js#L59
Since: 3.0.0


Inherited Methods

From Phaser.GameObjects.LightsManager:


Public Methods

boot

<instance> boot()

Description:

Handles the boot event from the Scene's Event Emitter, subscribing to the Scene's shutdown and destroy events so the plugin can clean up its resources when the Scene is stopped or destroyed.

Source: src/gameobjects/lights/LightsPlugin.js#L76
Since: 3.0.0


destroy

<instance> destroy()

Description:

Destroy the Lights Plugin.

Cleans up all references.

Overrides: Phaser.GameObjects.LightsManager#destroy

Source: src/gameobjects/lights/LightsPlugin.js#L92
Since: 3.0.0