Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides sounds for your game!

Example

const ding = new Sound('assets/sounds/ding.ogg')

// When the sound should play.
ding.play()

Hierarchy

  • Sound

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Initialize Sound object.

    Parameters

    • src: string

      Source for the sound.

    • Default value options: SoundOptions = { volume: 1, loop: false }

      Initial options for the sound.

    Returns Sound

Properties

playing

playing: boolean

Whether or not the sound is currently playing.

Accessors

volume

  • get volume(): number
  • set volume(volume: number): void
  • Gets the current volume setting.

    Returns number

  • Sets the volume of the sound.

    Parameters

    • volume: number

    Returns void

Methods

play

  • Play the sound from the beginning.

    Parameters

    • Optional overrides: SoundOptions

      Overriding options for the sound.

    Returns void

stop

  • stop(): void