API Docs for: 1.13.1
Show:

game.Audio Class

Extends game.Class
Defined in: engine/audio.js:11
Module: audio

Methods

extend

(
  • prop
)
game.Class

Inherited from game.Class: engine/core.js:757

Extend class.

Parameters:

  • prop Object

Returns:

init

(
  • arguments
)

Inherited from game.Class: engine/core.js:811

This method is called, when you create new instance of the class.

Parameters:

  • arguments Array

inject

(
  • prop
)

Inherited from game.Class: engine/core.js:825

Inject class.

Parameters:

  • prop Object

isMusicPlaying

() Boolean

Defined in engine/audio.js:625

Check if music is playing.

Returns:

Boolean:

isSoundPlaying

(
  • id
)
Boolean

Defined in engine/audio.js:615

Check if sound is playing.

Parameters:

  • id Number

Returns:

Boolean:

muteMusic

()

Defined in engine/audio.js:522

Mute current music.

muteSound

(
  • [id]
)
Boolean

Defined in engine/audio.js:421

Mute specific sound or all sounds.

Parameters:

  • [id] Number optional

    Id of sound

Returns:

Boolean:

pauseMusic

() Boolean

Defined in engine/audio.js:503

Pause current music.

Returns:

Boolean:

pauseSound

(
  • [id]
)
Boolean

Defined in engine/audio.js:378

Pause specific or all sounds.

Parameters:

  • [id] Number optional

    Id of sound

Returns:

Boolean:

Return false, if sound is not playing

playMusic

(
  • name
  • [loop]
)
Boolean

Defined in engine/audio.js:467

Play music.

Parameters:

  • name Number

    Name of music

  • [loop] Boolean optional

    Music looping

Returns:

Boolean:

playSound

(
  • name
  • [loop]
  • [callback]
  • [rate]
)
Number

Defined in engine/audio.js:342

Play sound.

Parameters:

  • name String

    Name of sound

  • [loop] Boolean optional

    Sound looping

  • [callback] Function optional

    Callback when sound is finished

  • [rate] Number optional

    Playback rate (Web Audio)

Returns:

Number:

id

resumeMusic

() Boolean

Defined in engine/audio.js:513

Resume current music.

Returns:

Boolean:

resumeSound

(
  • id
)
Boolean

Defined in engine/audio.js:404

Resume sound.

Parameters:

  • id Number

    Id of sound

Returns:

Boolean:

Return false, if sound is not paused

setMusicVolume

(
  • value
)

Defined in engine/audio.js:584

Change main music volume.

Parameters:

  • value Number

setPlaybackRate

(
  • id
  • rate
)

Defined in engine/audio.js:602

Change audio playback rate (Web Audio).

Parameters:

  • id Number
  • rate Number

setSoundVolume

(
  • value
)

Defined in engine/audio.js:556

Change main sound volume.

Parameters:

  • value Number

setVolume

(
  • id
  • value
)

Defined in engine/audio.js:540

Set volume for specific audio.

Parameters:

  • id Number
  • value Number

staticInit

(
  • arguments
)

Inherited from game.Class: engine/core.js:795

This method is called before init.

Parameters:

  • arguments Array

stopMusic

() Boolean

Defined in engine/audio.js:487

Stop current music.

Returns:

Boolean:

stopSound

(
  • [id]
  • [skipCallback]
)
Boolean

Defined in engine/audio.js:359

Stop specific or all sounds.

Parameters:

  • [id] Number optional

    Id of sound

  • [skipCallback] Boolean optional

    Skip callback function

Returns:

Boolean:

toggleMusic

() Boolean

Defined in engine/audio.js:647

Toggle music on/off.

Returns:

Boolean:

toggleSound

() Boolean

Defined in engine/audio.js:634

Toggle sounds on/off.

Returns:

Boolean:

unmuteMusic

()

Defined in engine/audio.js:531

Unmute current music.

unmuteSound

(
  • [id]
)
Boolean

Defined in engine/audio.js:444

Unmute specific sound or all sounds.

Parameters:

  • [id] Number optional

    Id of sound

Returns:

Boolean:

Properties

currentMusic

Number

Defined in engine/audio.js:35

Current music id.

currentMusicName

String

Defined in engine/audio.js:40

Name of current music.

formats

Array

Defined in engine/audio.js:20

List of supported audio formats.

musicMuted

Boolean

Defined in engine/audio.js:45

Is music muted.

Default: false

pausedSounds

Array

Defined in engine/audio.js:30

List of paused sounds.

playingSounds

Array

Defined in engine/audio.js:25

List of playing sounds.

soundMuted

Boolean

Defined in engine/audio.js:51

Is sounds muted.

Default: false

Attributes

enabled

Boolean

Defined in engine/audio.js:681

Enable audio.

Default: true

formats

Array

Defined in engine/audio.js:693

List of available audio formats.

musicVolume

Number

Defined in engine/audio.js:714

Music volume.

Default: 1

soundVolume

Number

Defined in engine/audio.js:708

Sound volume.

Default: 1

stopOnSceneChange

Boolean

Defined in engine/audio.js:702

Stop audio, when changing scene.

Default: true

webAudio

Boolean

Defined in engine/audio.js:687

Enable Web Audio.

Default: true