Class: Light

Phaser.GameObjects. Light

A 2D point light.

These are typically created by a Phaser.GameObjects.LightsManager, available from within a scene via this.lights.

Any Game Objects using the Light2D pipeline will then be affected by these Lights.

They can also simply be used to represent a point light for your own purposes.


new Light(x, y, radius, r, g, b, intensity)

Parameters:
Name Type Description
x number

The horizontal position of the light.

y number

The vertical position of the light.

radius number

The radius of the light.

r number

The red color of the light. A value between 0 and 1.

g number

The green color of the light. A value between 0 and 1.

b number

The blue color of the light. A value between 0 and 1.

intensity number

The intensity of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 10)

Members


b :number

The blue color of the light. A value between 0 and 1.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 84)

g :number

The green color of the light. A value between 0 and 1.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 75)

intensity :number

The intensity of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 93)

r :number

The red color of the light. A value between 0 and 1.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 66)

radius :number

The radius of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 57)

scrollFactorX :number

The horizontal scroll factor of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 102)

scrollFactorY :number

The vertical scroll factor of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 111)

x :number

The horizontal position of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 39)

y :number

The vertical position of the light.

Type:
  • number
Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 48)

Methods


set(x, y, radius, r, g, b, intensity)

Set the properties of the light.

Sets both horizontal and vertical scroll factor to 1. Use Phaser.GameObjects.Light#setScrollFactor to set
the scroll factor.

Parameters:
Name Type Description
x number

The horizontal position of the light.

y number

The vertical position of the light.

radius number

The radius of the light.

r number

The red color. A value between 0 and 1.

g number

The green color. A value between 0 and 1.

b number

The blue color. A value between 0 and 1.

intensity number

The intensity of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 121)
Returns:

This Light object.

Type
Phaser.GameObjects.Light

setColor(rgb)

Set the color of the light from a single integer RGB value.

Parameters:
Name Type Description
rgb number

The integer RGB color of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 181)
Returns:

This Light object.

Type
Phaser.GameObjects.Light

setIntensity(intensity)

Set the intensity of the light.

Parameters:
Name Type Description
intensity number

The intensity of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 202)
Returns:

This Light object.

Type
Phaser.GameObjects.Light

setPosition(x, y)

Set the position of the light.

Parameters:
Name Type Description
x number

The horizontal position of the light.

y number

The vertical position of the light.

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

This Light object.

Type
Phaser.GameObjects.Light

setRadius(radius)

Set the radius of the light.

Parameters:
Name Type Description
radius number

The radius of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 238)
Returns:

This Light object.

Type
Phaser.GameObjects.Light

setScrollFactor(x, y)

Set the scroll factor of the light.

Parameters:
Name Type Description
x number

The horizontal scroll factor of the light.

y number

The vertical scroll factor of the light.

Since: 3.0.0
Source: src/gameobjects/lights/Light.js (Line 159)
Returns:

This Light object.

Type
Phaser.GameObjects.Light