我现在用的是cocos2d-x 3.0 的正式版,在使用背景音乐和音效时遇到了一个问题,
就是在我没有播放背景音乐时,点击按钮播放音效时无效的,
当我播放过一次背景音乐后,然后再点击按钮播放音效就可以了,
之后停止了背景音乐的播放也没问题了
不知道问题出在哪里,有遇到过的朋友可否帮忙分析下
下面贴上我的代码
//播放按钮音效
void MyFunc::playButtonSound(const char* soundname){
SimpleAudioEngine::getInstance()->playEffect(soundname);
SimpleAudioEngine::getInstance()->setEffectsVolume(DataUtil::getFloat(KEY_VOLUME_EFFECTS));
}
//播放背景音乐
void MyFunc::playBackgroundSound(){
log("playBackgroundSound");
SimpleAudioEngine::getInstance()->playBackgroundMusic(file_s_background, true);
SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(DataUtil::getFloat(KEY_VOLUME_BACKGROUND));
}
```
之前分析可能是因为没有预加载音效的问题,然后我在onEnter方法中添加了预加载音效,不过好像还是同样的结果
void MainScene::onEnter(){
auto sae = SimpleAudioEngine::getInstance();
sae->preloadEffect(file_s_but1);
sae->preloadEffect(file_s_but2);
sae->preloadEffect(file_s_props);
MainScene::initSceneUI();
MainScene::initTouchEvent();
Layer::onEnter();
}
```
不知道问题出在哪里,我那个各位能帮忙分析一下

