melonJS
    Preparing search index...

    Class ShakeEffect

    A camera effect that shakes the viewport by applying random offsets.

    camera.addCameraEffect(new ShakeEffect(camera, {
    intensity: 10,
    duration: 500,
    axis: camera.AXIS.BOTH,
    }));

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • camera: Camera2d

        the camera to shake

      • options: { axis?: number; duration: number; intensity: number; onComplete?: () => void }

        shake parameters

        • Optionalaxis?: number

          which axes (NONE=0, HORIZONTAL=1, VERTICAL=2, BOTH=3)

        • duration: number

          duration in milliseconds

        • intensity: number

          maximum offset in pixels

        • OptionalonComplete?: () => void

          callback when the shake finishes

      Returns ShakeEffect

    Properties

    axis: number

    which axes to shake (use camera.AXIS constants)

    camera: Camera2d

    the camera this effect is attached to

    duration: number

    remaining duration in milliseconds

    intensity: number

    maximum pixel offset during shake

    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
    
    onComplete: (() => void) | undefined

    optional callback when shake completes

    Methods