PokéRogue
    Preparing search index...

    Class NoAudioSoundManager

    No-audio implementation of the Sound Manager. It is used if audio has been disabled in the game config or the device doesn't support any audio.

    It represents a graceful degradation of Sound Manager logic that provides minimal functionality and prevents Phaser projects that use audio from breaking on devices that don't support any audio playback technologies.

    Hierarchy (View Summary)

    Index
    detune: number

    Global detuning of all sounds in cents. The range of the value is -1200 to 1200, but we recommend keeping it within a reasonable range for musical purposes.

    game: Game

    Local reference to game.

    gameLostFocus: boolean

    Flag used to track if the game has lost focus.

    jsonCache: BaseCache

    Local reference to the JSON Cache, as used by Audio Sprites.

    listenerPosition: Vector2

    The Spatial Audio listener position.

    Only available with WebAudio.

    You can modify the x/y properties of this Vec2 directly to adjust the listener position within the game world.

    locked: boolean

    Mobile devices require sounds to be triggered from an explicit user action, such as a tap, before any sound can be loaded/played on a web page. Set to true if the audio system is currently locked awaiting user interaction.

    mute: boolean

    Global mute setting.

    pauseOnBlur: boolean

    Flag indicating if sounds should be paused when game loses focus, for instance when user switches to another tab/program/app.

    rate: number

    Global playback rate at which all the sounds will be played. Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed and 2.0 doubles the audio's playback speed.

    volume: number

    Global volume setting.

    • Adds a new sound into the sound manager.

      Parameters

      • key: string

        Asset key for the sound.

      • Optionalconfig: SoundConfig

        An optional config object containing default sound settings.

      Returns NoAudioSound

      The new sound instance.

    • Adds a new audio sprite sound into the sound manager. Audio Sprites are a combination of audio files and a JSON configuration. The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite

      Parameters

      • key: string

        Asset key for the sound.

      • Optionalconfig: SoundConfig

        An optional config object containing default sound settings.

      Returns NoAudioSound

      The new audio sprite sound instance.

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • Destroys all the sounds in the game and all associated events.

      Returns void

    • Calls each of the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • ...args: any[]

        Additional arguments that will be passed to the event handler.

      Returns boolean

      true if the event had listeners, else false.

    • Return an array listing the events for which the emitter has registered listeners.undefined

      Returns (string | symbol)[]

      undefined

    • Gets the first sound in the manager matching the given key, if any.

      Type Parameters

      Parameters

      • key: string

        Sound asset key.

      Returns T

      • The sound, or null.
    • Gets any sounds in the manager matching the given key.

      Type Parameters

      Parameters

      • key: string

        Sound asset key.

      Returns T[]

      • The sounds, or an empty array.
    • Returns all sounds from this Sound Manager that are currently playing. That is, Sound instances that have their isPlaying property set to true.undefined

      Type Parameters

      Returns T[]

      • All currently playing sounds, or an empty array.
    • When a key is given, returns true if any sound with that key is playing.

      When no key is given, returns true if any sound is playing.

      Parameters

      • key: string | undefined

        Sound asset key.

      Returns boolean

      • Per the key argument, true if any matching sound is playing, otherwise false.
    • Return the number of listeners listening to a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns number

      The number of listeners.

    • Return the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns Function[]

      The registered listeners.

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

      this.

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would be called when the browser window loses focus and would pause all playing sounds if pauseOnBlur is enabled.

      Returns void

    • Add a one-time listener for a given event. The listener is automatically removed the first time the event is emitted, so it will never be called more than once.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would be called when the browser window regains focus and would resume any sounds that were paused when focus was lost.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would be called when the Phaser Game instance loses focus (e.g. the canvas loses the pointer) and would pause sounds accordingly.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would be called when the Phaser Game instance regains focus and would resume any sounds that were paused on blur.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would pause all currently playing sounds.

      Returns void

    • This method does nothing but return 'false' for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      Parameters

      • key: string

        Asset key for the sound.

      • Optionalextra: SoundConfig | SoundMarker

        An optional additional object containing settings to be applied to the sound. It could be either config or marker object.

      Returns boolean

      Always 'false' for the No Audio Sound Manager.

    • This method does nothing but return 'false' for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      Parameters

      • key: string

        Asset key for the sound.

      • spriteName: string

        The name of the sound sprite to play.

      • Optionalconfig: SoundConfig

        An optional config object containing default sound settings.

      Returns boolean

      Always 'false' for the No Audio Sound Manager.

    • Removes a sound from the sound manager. The removed sound is destroyed before removal.

      Parameters

      • sound: BaseSound

        The sound object to remove.

      Returns boolean

      True if the sound was removed successfully, otherwise false.

    • Removes all sounds from the manager, destroying the sounds.

      Returns void

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: string | symbol

        The event name.

      Returns this

      this.

    • Removes all sounds from the sound manager that have an asset key matching the given value. The removed sounds are destroyed before removal.

      Parameters

      • key: string

        The key to match when removing sound objects.

      Returns number

      The number of matching sound objects that were removed.

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

      this.

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would resume all paused sounds.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would set the global detune value for all sounds, measured in cents, where 100 cents equals one semitone.undefined

      Returns this

      This Sound Manager.

    • Sets the X and Y position of the Spatial Audio listener on this Web Audio context.

      If you call this method with no parameters it will default to the center-point of the game canvas. Depending on the type of game you're making, you may need to call this method constantly to reset the listener position as the camera scrolls.

      Calling this method does nothing on HTML5Audio.

      Parameters

      • Optionalx: number

        The x position of the Spatial Audio listener.

      • Optionaly: number

        The y position of the Spatial Audio listener.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would mute or unmute all sounds in the manager.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would set the global playback rate for all sounds, where 1 is normal speed, 0.5 is half speed, and 2 is double speed.undefined

      Returns this

      This Sound Manager.

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would set the global volume for all sounds in the manager, where 0 is silent and 1 is full volume.

      Returns void

    • Removes all listeners from this EventEmitter. This method is called automatically by the Scene Systems when the parent Scene shuts down, ensuring that all event bindings are cleared and no stale references remain.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would stop all currently playing sounds.

      Returns void

    • Stops any sounds matching the given key.

      Parameters

      • key: string

        Sound asset key.

      Returns number

      • How many sounds were stopped.
    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would attempt to unlock the audio context after a user gesture, which is required by modern browsers before audio playback can begin.

      Returns void

    • This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

      In a real Sound Manager, this would be called on each game step to update the state of all active sounds.

      Returns void