Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Sound

Sound that is played in DX Engine.

All sounds require a sound asset id and need to be fully loaded before they can be played.

Hierarchy

  • Sound

Implements

Index

Properties

Private _typeTag0

_typeTag0: "Sound"

currentPosition

currentPosition: number

Defines the track position of this Sound.

duration

duration: number

Returns duration of this Sound in seconds.

volume

volume: number

Defines the normalized volume of this Sound. Volume value is clamped to range [0,1]

Methods

dispose

  • dispose(): void
  • Disposes this object, effectively turning this into an unmanaged resource.

    Returns void

isPlaying

  • isPlaying(): boolean
  • Returns true if the sound is currently playing

    Returns boolean

pause

  • pause(): void
  • Pauses playback of this Sound.

    The sound resumes at the same track position with next play call.

    Returns void

play

  • play(): void
  • play(onFinish: function): void
  • play(looping: boolean): void
  • Plays this Sound.

    If the sound is not fully loaded, the playback will delay until loading is complete.

    Returns void

  • Plays this Sound.

    If the sound is not fully loaded, the playback will delay until loading is complete.

    Parameters

    • onFinish: function

      callback function when the Sound finishes.

        • (): void
        • Returns void

    Returns void

  • Plays this Sound.

    If the sound is not fully loaded, the playback will delay until loading is complete.

    Parameters

    • looping: boolean

      if true, this Sound loops indefinitely.

    Returns void

stop

  • stop(): void
  • Stops playback of this Sound.

    The sound starts from the beginning with next play call.

    Returns void

Static load

  • load(id: string): Sound
  • load(id: string, callback: function): Sound
  • Loads a sound via the provided sound id.

    Parameters

    • id: string

      sound asset id.

    Returns Sound

    loaded Sound.

  • Loads a sound via the provided sound id.

    Parameters

    • id: string

      sound asset id.

    • callback: function

      triggers once the Sound is fully loaded.

        • Parameters

          Returns void

    Returns Sound

    loaded Sound.

Static playOneShot

  • playOneShot(sound: Sound, volume: number): void
  • Plays a oneshot sound based on the provided, loaded Sound.

    Oneshot sounds can be played multiple times from the same Sound source and are useful for repeating sound effects like rain and foot steps.

    Parameters

    • sound: Sound

      sound to play once.

    • volume: number

      normalized volume at which to play the sound.

    Returns void

Static stopAll

  • stopAll(): void
  • Stops all sounds that are currently playing.

    Returns void

Static stopById

  • stopById(soundIds: Iterable<string>): void
  • stopById(soundId: string): void
  • Stops all sounds by their sound asset id.

    Parameters

    • soundIds: Iterable<string>

      array of sound asset ids.

    Returns void

  • Stops a sound by its sound asset id.

    Parameters

    • soundId: string

      array of sound asset ids.

    Returns void

Generated using TypeDoc