jetlag2d
    Preparing search index...

    Interface ISound

    An abstract representation of a sound

    We use ISound so that the rest of JetLag doesn't need to know about Howler, but an ISound is really just a Howl object.

    NB: Sound effects don't currently pause when a pause screen is showing.

    interface ISound {
        pause(id?: number): void;
        play(): number;
        playing(id?: number): boolean;
        rate(id?: number): number;
        rate(rate: number, id?: number): this;
        seek(id?: number): number;
        seek(seek: number, id?: number): this;
        stop(id?: number): void;
        volume(id?: number): number;
        volume(volume: number, id?: number): this;
    }
    Index
    • Pause the sound, so we can resume it later via play()

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to pause. Omit to pause all instances.

      Returns void

    • Play the sound, as a new, independent instance (the same sound can be played more than once concurrently)

      Returns number

      An id for this specific instance of the sound, for use with the other methods below, so they can control this instance without affecting any other concurrently-playing instance of the same sound

    • Report if the sound is currently playing

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to check. Omit to report if any instance of the sound is playing.

      Returns boolean

    • Get the playback rate (speed) of the sound. 1 is normal, 2 is twice as fast (and an octave higher), and 0.5 is half as fast (and an octave lower).

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to query. Omit to query the most recent instance.

      Returns number

    • Change the playback rate (speed) of the sound. Since a faster sound is also higher, this is how to play one recording at different pitches.

      Parameters

      • rate: number

        The new rate: 1 is normal, 2 is twice as fast, and 0.5 is half as fast

      • Optionalid: number

        The id (from play()) of the specific instance to change. Omit to change all instances.

      Returns this

    • Get the current playback position (in seconds)

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to query. Omit to query the most recent instance.

      Returns number

    • Move the playback position to seek (in seconds)

      Parameters

      • seek: number

        The new playback position, in seconds

      • Optionalid: number

        The id (from play()) of the specific instance to move. Omit to move the most recent instance.

      Returns this

    • Stop playing the sound, resetting its playback position to the start

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to stop. Omit to stop all instances.

      Returns void

    • Get the volume of the sound

      Parameters

      • Optionalid: number

        The id (from play()) of the specific instance to query. Omit to query the most recent instance.

      Returns number

    • Change the volume of the sound

      Parameters

      • volume: number

        The new volume, from 0 (silent) to 1 (full)

      • Optionalid: number

        The id (from play()) of the specific instance to change. Omit to change all instances.

      Returns this