The Displacement FX Controller.
This FX controller manages the displacement effect for a Game Object.
The displacement effect is a visual technique that alters the position of pixels in an image or texture based on the values of a displacement map. This effect is used to create the illusion of depth, surface irregularities, or distortion in otherwise flat elements. It can be applied to characters, objects, or backgrounds to enhance realism, convey movement, or achieve various stylistic appearances.
A Displacement effect is added to a Game Object via the FX component:
const sprite = this.add.sprite();
sprite.preFX.addDisplacement();
sprite.postFX.addDisplacement();
new Displacement(gameObject, [texture], [x], [y])
name | type | arguments | Default | description |
---|---|---|---|---|
gameObject | Phaser.GameObjects.GameObject |
A reference to the Game Object that has this fx. |
||
texture | string | <optional> | '__WHITE' |
The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. |
x | number | <optional> | 0.005 |
The amount of horizontal displacement to apply. A very small float number, such as 0.005. |
y | number | <optional> | 0.005 |
The amount of vertical displacement to apply. A very small float number, such as 0.005. |
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.
A reference to the Game Object that owns this effect.
The underlying texture used for displacement.
The FX_CONST type of this effect.
The amount of horizontal displacement to apply.
The amount of vertical displacement to apply.
Destroys this FX Controller.
Sets the active state of this FX Controller.
A disabled FX Controller will not be updated.
name | type | description |
---|---|---|
value | boolean |
|
This FX Controller instance.
Sets the Texture to be used for the displacement effect.
You can only use a whole texture, not a frame from a texture atlas or sprite sheet.
name | type | arguments | Default | description |
---|---|---|---|---|
texture | string | <optional> | '__WHITE' |
The unique string-based key of the texture to use for displacement, which must exist in the Texture Manager. |
This FX Controller.