cocos2dx中可以使用SimpleAudioEngine音频引擎添加和管理项目中的音频和特效,SimpleAudioEngine是一个共享的单例对象,
1,SimpleAudioEngine简介
SimpleAudioEngine在扩展库libAudio中,使用的时候需添加进项目中,声明在命名空间namespace:CocosDenshion中。
播放:
SimpleAudioEngine::getInstance()->playBackgroundMusic("background.mp3",true);
SimpleAudioEngine::getInstance()->playBackgroundMusic("background.mp3",false);
SimpleAudioEngine::getInstance()->playEffect("background.mp3",false,1.0,1.0);
暂停:
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseEffect();
SimpleAudioEngine::getInstance()->pauseAllEffects();
恢复:
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
SimpleAudioEngine::getInstance()->resumeEffect();
SimpleAudioEngine::getInstance()->resumeAllEffects();
停止:
SimpleAudioEngine::getInstance()->stopBackgroundMusic();
SimpleAudioEngine::getInstance()->stopEffect();
SimpleAudioEngine::getInstance()->stopAllEffects();