melonJS
    Preparing search index...

    Class FlashEffect

    A shader effect that flashes the sprite with a solid color. Commonly used for hit feedback — flash white when the player takes damage. The intensity uniform controls how much of the flash color is mixed in (0.0 = original sprite, 1.0 = fully colored).

    Renderable.shader for usage

    // create a white flash effect
    const flash = new FlashEffect(renderer);
    mySprite.shader = flash;

    // trigger the flash (e.g. on hit)
    flash.setIntensity(1.0);

    // fade it out over time (e.g. in update loop)
    flash.setIntensity(flash.intensity - dt / 200);
    // red flash
    const flash = new FlashEffect(renderer, { color: [1.0, 0.0, 0.0] });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _enabledBeforeSuspend: boolean | undefined
    destroyed: boolean = false

    true once destroy has been called. Distinct from enabled — which also toggles transiently across a context lost / restored cycle — to give callers a stable signal for "this effect has been explicitly released."

    enabled: boolean = false

    whether this effect is active (false in Canvas mode, false after destroy, and false while the WebGL context is suspended between an ONCONTEXT_LOST and the matching ONCONTEXT_RESTORED event).

    intensity: number

    Methods