This class is responsible for manipulating background musics (BGM) and sound effect audios (SFX) of the engine.

Constructors

Properties

_current_bgm: Sound = null
bgm_volume: number
data: GoldenSun
game: Game
playing_bgms: {
    [id_key: string]: Phaser.Sound;
} = {}

Type declaration

  • [id_key: string]: Phaser.Sound
se_data: {
    [se_key: string]: Phaser.AudioSprite;
} = {}

Type declaration

  • [se_key: string]: Phaser.AudioSprite
DEFAULT_BGM_VOLUME: 0.6 = 0.6

Default bgm volume

VOLUME_ALTER_LOOP_TIME: 100 = 100

Volume change held threshold

VOLUME_STEP: 0.05 = 0.05

Volume step to apply upon volume altering

Accessors

  • get current_bgm(): Sound
  • The current BGM Phaser.Sound object.

    Returns Sound

Methods

  • Registers a sound effect in the engine.

    Parameters

    • se_key: string

      the sound effect key name.

    Returns void

  • Changes the game volume.

    Parameters

    • delta: number

      Delta to apply to the volume

    Returns number

    Final game volume

  • Gets the Phaser.Sound object of a bgm.

    Parameters

    • bgm_identifier: string

      the bgm identifier.

    Returns Sound

    the bgm Phaser.Sound object.

  • Initializes the game sound effects.

    Returns Promise<void>

  • Initializes mute and volume alter controls.

    Returns void

  • Pauses a bgm.

    Parameters

    • Optional bgm_identifier: string

      the bgm identifier to be paused. If not passed, it will pause current bgm.

    • fade_out: boolean = false

      if true, the bgm will fade out before pausing.

    • fade_duration: number = 750

      the fadeout duration in ms.

    Returns void

  • Plays the current active battle bgm.

    Returns void

  • Plays current activated bgm sound.

    Parameters

    • loop: boolean = true

      Whether the bgm should loop or not.

    • Optional volume: number

      The volume to be applied. [0,1].

    • Optional on_complete: (() => void)

      On bgm complete callback.

        • (): void
        • Returns void

    • fade_in: boolean = false

      if true, the bgm will fade in on start.

    • fade_duration: number = 750

      The fade in duration in ms.

    Returns void

  • Adds a new BGM audio to Phaser sound manager and plays it. You can give an unique name for this BGM by passing 'bgm_identifier' argument.

    Parameters

    • bgm_key: string

      The bgm key name registered in the json db.

    • loop: boolean = true

      Whether the bgm should loop or not.

    • Optional volume: number

      The volume to be applied. [0,1].

    • Optional on_complete: (() => void)

      On bgm complete callback.

        • (): void
        • Returns void

    • fade_in: boolean = false

      if true, the bgm will fade in on start.

    • fade_duration: number = 750

      The fade in duration in ms.

    • Optional bgm_identifier: string

      an unique name for this bgm.

    Returns Sound

    returns the Phaser.Sound object.

  • Plays a registered sound effect.

    Parameters

    • key: string

      the sound effect key name.

    • Optional on_stop: Function

      on sfx stop callback function.

    • position_shift: number = 0

      the amount of time in sec. to initially cut of this sfx.

    • volume: number = 1

      the volume that it will be plays. [0,1].

    Returns Sound

    Returns the Phaser.Sound instance.

  • Plays a registered sound effect, pausing the current bgm before and resuming it after

    Parameters

    • key: string

      the sound effect key name.

    • position_shift: number = 0

      the amount of time in sec. to initially cut of this sfx.

    • volume: number = 1

      the volume that it will be plays. [0,1].

    Returns void

  • Resumes the current bgm sound that was paused.

    Returns void

  • Sets the current bgm object to played by the engine.

    Parameters

    • bgm_key: string

      The bgm key name.

    • play: boolean = false

      whether is to already start playing.

    Returns void

  • Stops a bgm. If 'bgm_identifier', the bgm entry is removed on stop finish.

    Parameters

    • Optional bgm_identifier: string

      the bgm identifier to be stopped. If not passed, it will stop current bgm.

    • fade_out: boolean = false

      if true, the bgm will fade out before stopping.

    • fade_duration: number = 750

      the fadeout duration in ms.

    Returns void