Reference Source Test
public class | source

Audio

Controls audio and sfx in the game

Constructor Summary

Public Constructor
public

constructor(instance: Game)

Default constructor

Member Summary

Public Members
public

An object with all of the music and sfxs

public

Whether or not music is on in the game

public

The format of the audibles

public

An instance of the game

public

All the music in the game

public

All the SFX in the game

public

An instance of the song

public

The name of the song

Method Summary

Public Methods
public

Clear the fade in interval

public

Clears the fade out interval

public

Fade in the active song

public

fadeOut(callback: Function): Boolean

Fade out the active song

public

Triggers the song to fade out and then resets it

public

checks to see if this song file exists in the music list

public

get(name: String): Boolean

Return the song

public

getMusic(name: String): {sound: HTMLAudioElement, name: String}

Returns an object with the sound and the name of the sound

public

Return the music volume

public

Return the SFX volume

public

Returns true if the users sound is enabled

public

Loads the music and sfx in the game

public

parse(path: String, name: String, channels: Array, callback: Function)

Default constructor

public

play(type: String, name: String): Boolean

Play a specific audio file

public

reset(song: *): Boolean

Resets a song so that it's ready to play from the beginning again

public

Set the volume level on the sound

public

Stop playing a song

public

Update a song to replay, fade in, fade out or reset

Public Constructors

public constructor(instance: Game) source

Default constructor

Params:

NameTypeAttributeDescription
instance Game

of the game

Public Members

public audibles: Object source

An object with all of the music and sfxs

public enabled: Boolean source

Whether or not music is on in the game

public format: String source

The format of the audibles

public game: Game source

An instance of the game

public music: Object source

All the music in the game

public sfx: Object source

All the SFX in the game

public song: Object source

An instance of the song

public songName: String source

The name of the song

Public Methods

public clearFadeIn(): Boolean source

Clear the fade in interval

Return:

Boolean

public clearFadeOut(): Boolean source

Clears the fade out interval

Return:

Boolean

public fadeIn(): Boolean source

Fade in the active song

Return:

Boolean

public fadeOut(callback: Function): Boolean source

Fade out the active song

Params:

NameTypeAttributeDescription
callback Function

trigger this callback when the fade out is done

Return:

Boolean

public fadeSongOut(): Boolean source

Triggers the song to fade out and then resets it

Return:

Boolean

public fileExists(name: String): Boolean source

checks to see if this song file exists in the music list

Params:

NameTypeAttributeDescription
name String

the name of the song

Return:

Boolean

returns true if it exists

public get(name: String): Boolean source

Return the song

Params:

NameTypeAttributeDescription
name String

the name of the song

Return:

Boolean

public getMusic(name: String): {sound: HTMLAudioElement, name: String} source

Returns an object with the sound and the name of the sound

Params:

NameTypeAttributeDescription
name String

the name of the music

Return:

{sound: HTMLAudioElement, name: String}

public getMusicVolume(): Number source

Return the music volume

Return:

Number

public getSFXVolume(): Number source

Return the SFX volume

Return:

Number

public isEnabled(): Boolean source

Returns true if the users sound is enabled

Return:

Boolean

public loadAudio() source

Loads the music and sfx in the game

public parse(path: String, name: String, channels: Array, callback: Function) source

Default constructor

Params:

NameTypeAttributeDescription
path String

to the audio file

name String

the name of the audio file

channels Array

an array of audio channels

callback Function

the function to call when done parsing the audio file

public play(type: String, name: String): Boolean source

Play a specific audio file

Params:

NameTypeAttributeDescription
type String

Module.AudioTypes.Music|Module.AudioTypes.SFX

name String

the name of the audio file

Return:

Boolean

public reset(song: *): Boolean source

Resets a song so that it's ready to play from the beginning again

Params:

NameTypeAttributeDescription
song *

Return:

Boolean

public setSongVolume(volume: Number): Boolean source

Set the volume level on the sound

Params:

NameTypeAttributeDescription
volume Number

the volume level

Return:

Boolean

public stop(): Boolean source

Stop playing a song

Return:

Boolean

public update(): Boolean source

Update a song to replay, fade in, fade out or reset

Return:

Boolean