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

    enabled: boolean = false

    whether this effect is active (false in Canvas mode)

    intensity: number

    Methods