- //预加载
- SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic("music_logo.mp3");
- //播放背景音乐
- SimpleAudioEngine::sharedEngine()->playBackgroundMusic("music_logo.mp3", true);
- //暂停播放
- SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
- //停止播放,还有一个函数带一个参数,表示是否释放该资源
- SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
- //设置音量,0.0-1.0
- SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
- //播放音效
- SimpleAudioEngine::sharedEngine()->playEffect("sound_button.mp3");
- //暂停某个音效
- SimpleAudioEngine::sharedEngine()->pauseEffect(unsigned int nSoundId);
- //暂停全部音效
- SimpleAudioEngine::sharedEngine()->pauseAllEffects();
- //停止某个音效
- SimpleAudioEngine::sharedEngine()->stopEffect(unsigned int nSoundId);
- //停止所有音效
- SimpleAudioEngine::sharedEngine()->stopAllEffects();
- //在程序不需要音乐时,释放sharedEngine()
- SimpleAudioEngine::sharedEngine()->end();
cocos2d 声音引擎
最新推荐文章于 2020-04-22 17:13:08 发布