Class: ShakeEffect

ShakeEffect()

new ShakeEffect()

Creates a screen shake visual effect.
Source:

Extends

  • BaseEffect

Methods

apply(mainContext, sceneCanvas, effectPipelineDataopt) → {Object}

Applies the screen shake by modifying the drawing offset.
Parameters:
Name Type Attributes Default Description
mainContext CanvasRenderingContext2D The context of the main (visible) canvas.
sceneCanvas HTMLCanvasElement The offscreen canvas containing the rendered scene content.
effectPipelineData object <optional>
{drawX: 0, drawY: 0} Data from previous effects.
Source:
Returns:
The modified draw offsets.
Type
Object

update(deltaTime)

Updates the shake effect's intensity over time if decay is enabled.
Parameters:
Name Type Description
deltaTime number The time elapsed since the last frame, in seconds.
Source:

ShakeEffect(options)

new ShakeEffect(options)

Creates an instance of ShakeEffect.
Parameters:
Name Type Description
options object Configuration options for the shake effect.
Properties
Name Type Attributes Default Description
intensity number <optional>
10 Maximum pixel offset for the shake.
duration number <optional>
500 Duration of the shake in milliseconds.
decay boolean <optional>
true Whether the shake intensity should decay over its duration.
Source:

Methods

apply(mainContext, sceneCanvas, effectPipelineDataopt) → {Object}

Applies the screen shake by modifying the drawing offset.
Parameters:
Name Type Attributes Default Description
mainContext CanvasRenderingContext2D The context of the main (visible) canvas.
sceneCanvas HTMLCanvasElement The offscreen canvas containing the rendered scene content.
effectPipelineData object <optional>
{drawX: 0, drawY: 0} Data from previous effects.
Source:
Returns:
The modified draw offsets.
Type
Object

update(deltaTime)

Updates the shake effect's intensity over time if decay is enabled.
Parameters:
Name Type Description
deltaTime number The time elapsed since the last frame, in seconds.
Source: