Skip to main content
Version: Phaser v4.0.0-rc.6

Phaser.GameObjects.Components.Lighting

Scope: static

Source: src/gameobjects/components/Lighting.js#L7
Since: 4.0.0

Static functions

lighting

lighting: boolean

Description:

Should this GameObject use lighting?

This flag is used to set up WebGL shaders for rendering.

Tags:

  • webglOnly

Source: src/gameobjects/components/Lighting.js#L18
Since: 4.0.0


selfShadow

selfShadow: Object

Description:

Should this GameObject use self-shadowing?

Self-shadowing is only enabled if lighting is enabled.

The game config option render.selfShadow is used if this is not a boolean.

This flag is used to set up WebGL shaders for rendering.

Tags:

  • webglOnly

Source: src/gameobjects/components/Lighting.js#L32
Since: 4.0.0


Static functions

setLighting

<instance> setLighting(enable)

Description:

Sets whether this GameObject should use lighting.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
enablebooleanNotrue to use lighting, or false to disable it.

Returns: Phaser.GameObjects.Components.Lighting - This GameObject instance.

Source: src/gameobjects/components/Lighting.js#L51
Since: 4.0.0


setSelfShadow

<instance> setSelfShadow([enabled], [penumbra], [diffuseFlatThreshold])

Description:

Sets whether this GameObject should use self-shadowing.

Self-shadowing is only enabled if lighting is also enabled.

Tags:

  • webglOnly

Parameters:

nametypeoptionaldescription
enabledbooleanYestrue to use self-shadowing, false to disable it, null to use the game default from config.render.selfShadow, or undefined to keep the setting.
penumbranumberYesThe penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5.
diffuseFlatThresholdnumberYesThe texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3.

Returns: Phaser.GameObjects.Components.Lighting - This GameObject instance.

Source: src/gameobjects/components/Lighting.js#L67
Since: 4.0.0