melonJS
    Preparing search index...

    Class FadeEffect

    A camera effect that fades the screen to or from a color overlay.

    // fade to black
    camera.addCameraEffect(new FadeEffect(camera, {
    color: "#000",
    duration: 500,
    direction: "in",
    }));
    // flash white then fade back
    camera.addCameraEffect(new FadeEffect(camera, {
    color: "#fff",
    duration: 200,
    direction: "out",
    }));

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • camera: Camera2d

        the camera to apply the fade to

      • options: {
            color: string | Color;
            direction?: "in" | "out";
            duration?: number;
            onComplete?: () => void;
        }

        fade parameters

        • color: string | Color

          CSS color value or Color instance

        • Optionaldirection?: "in" | "out"

          "in" fades to color, "out" fades from color to transparent

        • Optionalduration?: number

          fade duration in milliseconds

        • OptionalonComplete?: () => void

          callback when the fade finishes

      Returns FadeEffect

    Properties

    camera: Camera2d

    the camera this effect is attached to

    color: Color

    the overlay color

    direction: "in" | "out"

    fade direction: "in" fades to the color, "out" fades from the color back to transparent

    isComplete: boolean

    whether this effect has finished and should be removed

    isPersistent: boolean

    whether this effect should persist across camera/game resets (e.g. transition effects that span state changes)

    false
    
    tween: Tween

    the tween controlling alpha transition

    Methods