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();

原文链接:https://www.f2er.com/cocos2dx/343575.html

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