Game Development Reference
In-Depth Information
Adding background music
Still inside AppDelegate.cpp , we load the sound files we'll use in the game, including
a background.mp3 (courtesy of Kevin MacLeod from incompetech.com ), which we
load through the command:
auto audioEngine = SimpleAudioEngine::getInstance();
audioEngine->preloadBackgroundMusic(fileUtils->fullPathForFilename("background.mp3").c_str());
We end by setting the effects' volume down a tad:
//lower playback volume for effects
audioEngine->setEffectsVolume(0.4f);
For background music volume, you must use setBackgroundMusicVolume . If you
create some sort of volume control in your game, these are the calls you would make to ad-
just the volume based on the user's preference.
Search WWH ::




Custom Search