Class: LightsManager

Phaser.GameObjects. LightsManager

Manages Lights for a Scene.

Affects the rendering of Game Objects using the Light2D pipeline.


new LightsManager()

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 23)

Members


active :boolean

Whether the Lights Manager is enabled.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/lights/LightsManager.js (Line 59)

ambientColor :Phaser.Display.RGB

The ambient color.

Type:
Since: 3.50.0
Source: src/gameobjects/lights/LightsManager.js (Line 50)

lights :Array.<Phaser.GameObjects.Light>

The Lights in the Scene.

Type:
Since: 3.0.0
Default Value:
  • []
Source: src/gameobjects/lights/LightsManager.js (Line 40)

<readonly> maxLights :number

The maximum number of lights that a single Camera and the lights shader can process. Change this via the maxLights property in your game config, as it cannot be changed at runtime.

Type:
  • number
Since: 3.15.0
Source: src/gameobjects/lights/LightsManager.js (Line 69)

<readonly> visibleLights :number

The number of lights that the LightPipeline processed in the previous frame.

Type:
  • number
Since: 3.50.0
Source: src/gameobjects/lights/LightsManager.js (Line 80)

Methods


addLight( [x] [, y] [, radius] [, rgb] [, intensity])

Add a Light.

Parameters:
Name Type Argument Default Description
x number <optional>
0

The horizontal position of the Light.

y number <optional>
0

The vertical position of the Light.

radius number <optional>
100

The radius of the Light.

rgb number <optional>
0xffffff

The integer RGB color of the light.

intensity number <optional>
1

The intensity of the Light.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 232)
Returns:

The Light that was added.

Type
Phaser.GameObjects.Light

destroy()

Destroy the Lights Manager.

Cleans up all references by calling Phaser.GameObjects.LightsManager#shutdown.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 299)

disable()

Disable the Lights Manager.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 116)
Returns:

This Lights Manager object.

Type
Phaser.GameObjects.LightsManager

enable()

Enable the Lights Manager.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 96)
Returns:

This Lights Manager object.

Type
Phaser.GameObjects.LightsManager

getLightCount()

Get the number of Lights managed by this Lights Manager.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 219)
Returns:

The number of Lights managed by this Lights Manager.

Type
number

getLights(camera)

Get all lights that can be seen by the given Camera.

It will automatically cull lights that are outside the world view of the Camera.

If more lights are returned than supported by the pipeline, the lights are then culled based on the distance from the center of the camera. Only those closest are rendered.

Parameters:
Name Type Description
camera Phaser.Cameras.Scene2D.Camera

The Camera to cull Lights for.

Since: 3.50.0
Source: src/gameobjects/lights/LightsManager.js (Line 131)
Returns:

The culled Lights.

Type
Array.<Phaser.GameObjects.Light>

getMaxVisibleLights()

Returns the maximum number of Lights allowed to appear at once.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 206)
Returns:

The maximum number of Lights allowed to appear at once.

Type
number

removeLight(light)

Remove a Light.

Parameters:
Name Type Description
light Phaser.GameObjects.Light

The Light to remove.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 263)
Returns:

This Lights Manager object.

Type
Phaser.GameObjects.LightsManager

setAmbientColor(rgb)

Set the ambient light color.

Parameters:
Name Type Description
rgb number

The integer RGB color of the ambient light.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 187)
Returns:

This Lights Manager object.

Type
Phaser.GameObjects.LightsManager

shutdown()

Shut down the Lights Manager.

Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and culled Lights.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 285)