Adding looped background music
Cocos2d-x has a separate engine for the sound named CocosDenshion and uses the SimpleAudioEngine.h header. Whenever you want to include calls for any of its function, you will have to include this header. Similar to the CCDirector class, the Simple Audio Engine is also a singleton class that you will use to start, pause, resume, and stop a particular background sound or effect.
As you would have noticed, there are two types of audio in games—background music, which lasts for about usually 30 seconds to a minute and gets looped over time, and there are sound effects that get played when a certain event occurs, such as shooting a bullet or enemy getting hurt and it lasts a couple of seconds. Both files are called separately ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access