cocos2dx背景音乐

前端之家收集整理的这篇文章主要介绍了cocos2dx背景音乐前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


//初始化声音
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str() );
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str(),true);


//控制开关

//打开

SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathForFilename("background.mp3")).c_str(),true);

//关闭

SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();

猜你在找的Cocos2d-x相关文章