Games don't necessarily always need audio; there are many types of simple board and card games, for example, which have no audio at all. On mobile devices it's actually preferable to keep audio to a minimum in order to reduce load times, not to mention the fact that audio support still isn't exactly standardized on all devices. Further still, many users prefer to mute game audio in favor of the their own.

That said, JackyJS leverages the HowlerJS library to bring you cross platform support for your most basic audio needs. You can play multiple sound effects, loop background music, increase/decrease volume, mute/unmute, and save user settings to localStorage. Just remember to keep it simple. ;-)

JackyJS audio needs to be preloaded and assets initialized prior to use. The following example shows you how:


		GAME.Sound.asset(['gling.wav'], {name:'gling'});
		GAME.Sound.asset(['notify.wav'], {name:'notify'});
		GAME.Sound.asset(['music.mp3','music.ogg'], {
			name: 'music',
			type: 'music',
			loop: true
		var Level1 = GAME.Room.create({name:'Level1});

Properties (static)

Name Type Description
volumeSoundNumberthe global volume of sound assets. **read-only** (default: 50)
volumeMusicNumberthe global volume of music assets. **read-only** (default: 50)
mutedSoundBooleanthe global muting of sound assets. **read-only** (default: FALSE)
mutedMusicBooleanthe global muting of music assets. **read-only** (default: FALSE)

Methods (static)

Name Parameter Type Description
assetinitializes a resource asset to be used as a reference in the creation of entities. You can add fallback audio files to cover cases where a browser does not support a particular audio format. To do this, simply append to the src array different audio files. According to the HowlerJS documentation, the webm format is a very compatible format to use.
* srcArraysource filename of sound resource to initialize. Path not required. (default path: jackyjs/assets/sounds)
* options.nameStringname of asset.
options.typeStringtype of asset; 'sound' or 'music'. (default: 'sound')
options.loopBooleanif set to TRUE, will loop forever. (default: FALSE)
options.pausableBooleanif set to TRUE, sound can be paused. (default: FALSE)
playassetNameStringplays the sound referenced by assetName.
stopassetNameStringstops the sound file referenced by assetName, and resets its playhead to beginning.
pauseassetNameStringpauses the sound file referenced by assetName.
pauseToggle* assetNameStringtoggles pause/play state referenced by assetName.
overrideBooleanif set to TRUE, toggles pause/play state even if NOT pausable.
mute* assetNameStringmutes/unmutes the sound file referenced by assetName.
mutedBooleanTRUE is muted; FALSE is unmuted
muteToggletypeStringthe audio type to toggle mute/unmute. Options: 'sound', 'music', 'all'. (default: 'all')
stopAllstops ALL sound files, and resets their playhead to beginning.
pauseAllpauses ALL sound files.
muteAllmutedBooleanTRUE is muted; FALSE is unmuted.
typeStringthe audio type to mute/unmute. Options: 'sound', 'music', 'all'. (default: 'all')
muteToggleAlltoggles mute/unmute of ALL audio files.
volumeUp* typeStringincreases volume of specific audio type by 1 (max = 100). Options: 'sound', 'music'. (default: 'sound')
volumeDown* typeStringdecreases volume of specific audio type by 1 (min = 1). Options: 'sound', 'music'. (default: 'sound')
volumeUpAllincreases volume of ALL audio types.
volumeDownAlldecreases volume of ALL audio types.