Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Audio

Index

Constructors

Properties

_current_bgm: Sound = null
bgm_volume: number
data: GoldenSun
game: Game
playing_bgms: {} = {}

Type declaration

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

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

Methods

  • add_se(se_key: string): void
  • Registers a sound effect in the engine.

    Parameters

    • se_key: string

      the sound effect key name.

    Returns void

  • alter_volume(delta: number): number
  • Changes the game volume.

    Parameters

    • delta: number

      Delta to apply to the volume

    Returns number

    Final game volume

  • get_bgm_object(bgm_identifier: string): Sound
  • Gets the Phaser.Sound object of a bgm.

    Parameters

    • bgm_identifier: string

      the bgm identifier.

    Returns Sound

    the bgm Phaser.Sound object.

  • init_se(): Promise<void>
  • Initializes the game sound effects.

    Returns Promise<void>

  • initialize_controls(): void
  • Initializes mute and volume alter controls.

    Returns void

  • pause_bgm(bgm_identifier?: string, fade_out?: boolean, fade_duration?: number): 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

  • play_battle_bgm(): void
  • play_bgm(loop?: boolean, volume?: number, on_complete?: (() => void), fade_in?: boolean, fade_duration?: number): 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

  • play_parallel_bgm(bgm_key: string, loop?: boolean, volume?: number, on_complete?: (() => void), fade_in?: boolean, fade_duration?: number, bgm_identifier?: string): Sound
  • 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.

  • play_se(key: string, on_stop?: Function, position_shift?: number, volume?: number): Sound
  • 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.

  • play_se_pausing_bgm(key: string, position_shift?: number, volume?: number): void
  • 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

  • resume_bgm(): void
  • Resumes the current bgm sound that was paused.

    Returns void

  • set_bgm(bgm_key: string, play?: boolean): 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

  • stop_bgm(bgm_identifier?: string, fade_out?: boolean, fade_duration?: number): 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

Generated using TypeDoc