Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Building Android Games with Cocos2d-x
  • Toc
  • feedback
Building Android Games with Cocos2d-x

Building Android Games with Cocos2d-x

By : Hernandez
4.3 (8)
close
Building Android Games with Cocos2d-x

Building Android Games with Cocos2d-x

4.3 (8)
By: Hernandez

Overview of this book

If you have a basic understanding of the C++ programming language and want to create videogames for the Android platform, then this technology and book is ideal for you.
Table of Contents (10 chapters)
close
9
Index

Modifying audio properties


You can easily modify the background music and the basic audio properties of the sound effect by calling the setBackgroundMusicVolume method and the setEffectsVolume method. Both receive a float value as a parameter, where 0.0 means mute and 1.0 means maximum volume, as the following code listing shows:

SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(0.5f);
SimpleAudioEngine::getInstance()->setEffectsVolume(1.0f);

Handling audio when leaving the game

When the game activity is no longer active, the background music and the sound effects will not stop automatically, they should be stopped manually by removing the following comment block from the applicationDidEnterBackgound method in the AppDelegate class:

// if you use SimpleAudioEngine, it must be pause
 SimpleAudioEngine::getInstance()->pauseBackgroundMusic();

In order to make this new line of code work, we need to add the same line that we have added to the HelloWorld.cpp implementation file in...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete