Phaser API Documentation

  Version: 
Filter

The Shadow FX Controller.

This FX controller manages the shadow effect for a Game Object.

The shadow effect is a visual technique used to create the illusion of depth and realism by adding darker, offset silhouettes or shapes beneath game objects, characters, or environments. These simulated shadows help to enhance the visual appeal and immersion, making the 2D game world appear more dynamic and three-dimensional.

A Shadow effect is added to a Game Object via the FX component:

const sprite = this.add.sprite();

sprite.preFX.addShadow();
sprite.postFX.addShadow();

Constructor:

new Shadow(gameObject, [x], [y], [decay], [power], [color], [samples], [intensity])

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

A reference to the Game Object that has this fx.

x number <optional> 0

The horizontal offset of the shadow effect.

y number <optional> 0

The vertical offset of the shadow effect.

decay number <optional> 0.1

The amount of decay for shadow effect.

power number <optional> 1

The power of the shadow effect.

color number <optional> 0x000000

The color of the shadow.

samples number <optional> 6

The number of samples that the shadow effect will run for. An integer between 1 and 12.

intensity number <optional> 1

The intensity of the shadow effect.

Since: 3.60.0
Source: src/fx/Shadow.js (Line 11)

Extends


Members

active: boolean
Focus
Focus

Description:

Toggle this boolean to enable or disable this effect, without removing and adding it from the Game Object.

Only works for Pre FX.

Post FX are always active.

Type:
boolean
Inherited from: Phaser.FX.Controller#active
Since: 3.60.0
Source: src/fx/Controller.js (Line 47)
Focus
Focus
color: number
Focus
Focus

Description:

The color of the shadow.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 133)
Focus
Focus
decay: number
Focus
Focus

Description:

The amount of decay for the shadow effect.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 80)
Focus
Focus

Description:

A reference to the Game Object that owns this effect.

Type:
Inherited from: Phaser.FX.Controller#gameObject
Since: 3.60.0
Source: src/fx/Controller.js (Line 38)
Focus
Focus
glcolor: Array.<number>
Focus
Focus

Description:

The internal gl color array.

Type:
Array.<number>
Since: 3.60.0
Source: src/fx/Shadow.js (Line 98)
Focus
Focus
intensity: number
Focus
Focus

Description:

The intensity of the shadow effect.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 118)
Focus
Focus
power: number
Focus
Focus

Description:

The power of the shadow effect.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 89)
Focus
Focus
samples: number
Focus
Focus

Description:

The number of samples that the shadow effect will run for.

This should be an integer with a minimum value of 1 and a maximum of 12.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 107)
Focus
Focus
type: number
Focus
Focus

Description:

The FX_CONST type of this effect.

Type:
number
Inherited from: Phaser.FX.Controller#type
Since: 3.60.0
Source: src/fx/Controller.js (Line 29)
Focus
Focus
x: number
Focus
Focus

Description:

The horizontal offset of the shadow effect.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 62)
Focus
Focus
y: number
Focus
Focus

Description:

The vertical offset of the shadow effect.

Type:
number
Since: 3.60.0
Source: src/fx/Shadow.js (Line 71)
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Destroys this FX Controller.

Inherited from: Phaser.FX.Controller#destroy
Since: 3.60.0
Source: src/fx/Controller.js (Line 81)
Focus
Focus
setActive(value)
Focus
Focus

Description:

Sets the active state of this FX Controller.

A disabled FX Controller will not be updated.

Parameters:

name type description
value boolean

true to enable this FX Controller, or false to disable it.

Returns:
Description:

This FX Controller instance.

Inherited from: Phaser.FX.Controller#setActive
Since: 3.60.0
Source: src/fx/Controller.js (Line 62)
Focus
Focus