In order to add some music and effects to our game we'll create a module called AudioManager
that will take care of loading sounds and playing them.
First of all, we need to create a file called
audio_manager.lua
. This file will be in charge of managing all our sound needs. In this case we will use Untz, but you could easily modify it to use FMOD as follows:module ( "AudioManager", package.seeall ) local audio_definitions = { backgroundMusic = { type = RESOURCE_TYPE_SOUND, fileName = 'sounds/music.mp3', loop = true, volume = 1 }, jump = { type = RESOURCE_TYPE_SOUND, fileName = 'sounds/jump.wav', loop = false, volume = 1 } }
In the same way we defined the assets for our game, we will define all the sounds using the resource definition for the audio files. We saw this earlier in the Chapter 6, Resource Manager. If you don't understand what we're doing here, I suggest you go back and read about sound definitions in Chapter 6. The
sounds...