SimpleAudioEngine,背景音量在 playEffect 上降低然后备份

SimpleAudioEngine, background Volume down on playEffect then back up

在 Cocos2d (android) 我试图在 playEffect 运行时降低背景音量,然后在 playEffect 结束后将其恢复。我有这个代码:

auto audio = SimpleAudioEngine::getInstance();

audio->playBackgroundMusic("sound/abc-theme.mp3", true);

audio->setBackgroundMusicVolume(0.1);

audio->playEffect("sound/airplane.mp3", false, 1.0f, 1.0f, 1.0f);

audio->setBackgroundMusicVolume(1);

问题是我不知道如何让 playEffect 结束,此代码 "instantly" 将背景音乐设置为 1。如何在 PlayEffect 期间将背景音乐的音量设置为 0.1。

auto audio = SimpleAudioEngine::getInstance();

audio->playBackgroundMusic("sound/abc-theme.mp3", true);

audio->setBackgroundMusicVolume(0.1);

audio->playEffect("sound/airplane.mp3", false, 1.0f, 1.0f, 1.0f);

this->scheduleOnce(schedule_selector(LoadingScene::loadingCallBack), 1.0f);

创建函数

void ClassName::loadingCallBack(){

 audio->setBackgroundMusicVolume(1);

 }

我这样做过

 const float Delay=1.0f;
 this->runAction(Sequence::create(DelayTime::create(Delay),CallFunc::create(CC_CALLBACK_0(ABC::bgVolumeUp, this)),nullptr));

和函数

void ABC::bgVolumeUp(){

audio->setBackgroundMusicVolume(1);

}

基本上与pankaj建议的相似。他给了我这个方法的想法。