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 17)

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 77)

ambientColor :Object

The ambient color.

Type:
  • Object
Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 68)

culledLights :Array.<Phaser.GameObjects.Light>

Lights that have been culled from a Camera's viewport.

Lights in this list will not be rendered.

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

lightPool :Array.<Phaser.GameObjects.Light>

The pool of Lights.

Used to recycle removed Lights for a more efficient use of memory.

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

lights :Array.<Phaser.GameObjects.Light>

The Lights in the Scene.

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

<readonly> maxLights :integer

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:
  • integer
Since: 3.15.0
Source: src/gameobjects/lights/LightsManager.js (Line 87)

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 255)
Returns:

The Light that was added.

Type
Phaser.GameObjects.Light

cull(camera)

Cull any Lights that aren't visible to the given Camera.

Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered.

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

The Camera to cull Lights for.

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

The culled Lights.

Type
Array.<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 342)

disable()

Disable the Lights Manager.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 119)
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 99)
Returns:

This Lights Manager object.

Type
Phaser.GameObjects.LightsManager

forEachLight(callback)

Iterate over each Light with a callback.

Parameters:
Name Type Description
callback LightForEach

The callback that is called with each Light.

Since: 3.0.0
Source: src/gameobjects/lights/LightsManager.js (Line 180)
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 242)
Returns:

The number of Lights managed by this Lights Manager.

Type
integer

getMaxVisibleLights()

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

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

The maximum number of Lights allowed to appear at once.

Type
integer

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 298)
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 208)
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 321)