In my game, I have background music, and would like some background sound effects, with a few differences.
loop background music
if possible, have “crowd” noise in the background, also looping, but allow me to change volume
at the end of the play, possibly play 1, 2, or more sounds sequentially
For example, I’d like to play sounds “First Down!” “Penalty” “Injury” sequentially, rather than all at once.
Can AudioEngine do these things, or should I look at some other audio engine?
Along those lines, I don’t mind purchasing a third-party audio engine that I can include with my game, as long as it’s compatible with Cocos2d-x 3.16 and above, and won’t take me too long to incorporate. So I’m open to ideas!
Thanks,
Dogwalker
Ah, I found a suggestion online that is working great for the sequential sounds so far:
- Create a Vector<FiniteTimeAction<*> actions;
- for each sound, CallFunc::create(this{ play the sound }))
- after each sound, add a short delay (I don’t really know the sound lengths, but I’m close)
- when done, call this->runAction(Sequence::create(actions));
Works great!
1 Like
AudioEngine should do what you want. I’ll actually update docs about this.
SimpleAudioEngine will not do this by itself. Your thoughts above should help make this happen though.
I’m thinking of going with AudioEngine, so I can have background music and crowd noise, and change the volume of the crowd sounds. So, is it simpler to do sequential sounds (dynamic list of sounds, may change every play) with AudioEngine? My Sequence approach may work, but I’d rather do it the preferred way. Thanks!
Hey, by the way, I added AudioEngine::lazyInit() in my AppDelegate class. Is that recommended?
At this point, crowd sounds and music are both doing well, I just need to do a lot more testing (I’m just testing in the iphone simulator, will later test on my phone and in Windows). Great job!!