The Scene that this Lights Plugin belongs to.
Whether the Lights Manager is enabled.
The ambient color.
The Lights in the Scene.
ReadonlymaxThe 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.
A reference to the Scene that this Lights Plugin belongs to.
A reference to the Scene's systems.
ReadonlyvisibleThe number of lights processed in the previous frame.
Add a Light.
Optionalx: numberThe horizontal position of the Light. Default 0.
Optionaly: numberThe vertical position of the Light. Default 0.
Optionalradius: numberThe radius of the Light. Default 128.
Optionalrgb: numberThe integer RGB color of the light. Default 0xffffff.
Optionalintensity: numberThe intensity of the Light. Default 1.
Optionalz: numberThe z position of the light. If omitted, it will be set to radius * 0.1.
Creates a new Point Light Game Object and adds it to the Scene.
Note: This method will only be available if the Point Light Game Object has been built into Phaser.
The Point Light Game Object provides a way to add a point light effect into your game, without the expensive shader processing requirements of the traditional Light Game Object.
The difference is that the Point Light renders using a custom shader, designed to give the impression of a point light source, of variable radius, intensity and color, in your game. However, unlike the Light Game Object, it does not impact any other Game Objects, or use their normal maps for calcuations. This makes them extremely fast to render compared to Lights and perfect for special effects, such as flickering torches or muzzle flashes.
For maximum performance you should batch Point Light Game Objects together. This means ensuring they follow each other consecutively on the display list. Ideally, use a Layer Game Object and then add just Point Lights to it, so that it can batch together the rendering of the lights. You don't have to do this, and if you've only a handful of Point Lights in your game then it's perfectly safe to mix them into the display list as normal. However, if you're using a large number of them, please consider how they are mixed into the display list.
The renderer will automatically cull Point Lights. Those with a radius that does not intersect with the Camera will be skipped in the rendering list. This happens automatically and the culled state is refreshed every frame, for every camera.
The origin of a Point Light is always 0.5 and it cannot be changed.
Point Lights are a WebGL only feature and do not have a Canvas counterpart.
The horizontal position of this Point Light in the world.
The vertical position of this Point Light in the world.
Optionalcolor: numberThe color of the Point Light, given as a hex value. Default 0xffffff.
Optionalradius: numberThe radius of the Point Light. Default 128.
Optionalintensity: numberThe intensity, or color blend, of the Point Light. Default 1.
Optionalattenuation: numberThe attenuation of the Point Light. This is the reduction of light from the center point. Default 0.1.
Boot the Lights Plugin.
Destroy the Lights Plugin.
Cleans up all references.
Disable the Lights Manager.
Enable the Lights Manager.
Get the number of Lights managed by this Lights Manager.
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 renderer, the lights are then culled based on the distance from the center of the camera. Only those closest are rendered.
Returns the maximum number of Lights allowed to appear at once.
Set the ambient light color.
The integer RGB color of the ambient light.
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.
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:
For Game Objects to be affected by the Lights when rendered, you will need to set them to use lighting like so: