cocos2dx3.2 使用SimpleAudioEngine时不能播放音频解决办法(中文路径问题)

来源:互联网 发布:三国正史武将排名 知乎 编辑:程序博客网 时间:2024/06/07 01:30

cocos2dx windows下开发真是波折多多啊;最近又遇到了vs2013调试状态下能播放声音,非调试状态不能播放的问题。

跟了很多代码发现原来是带了中文路径的原因。故找到问题,马上解决掉

首先找到:libAudio工程下的SimpleAudioEngine.cpp文件

找到如下代码

//////////////////////////////////////////////////////////////////////////// static function//////////////////////////////////////////////////////////////////////////static std::string _FullPath(const char * szPath){      return FileUtils::getInstance()->fullPathForFilename(szPath);}

修改如下(我使用的是boost来转码的)

//////////////////////////////////////////////////////////////////////////// static function//////////////////////////////////////////////////////////////////////////static std::string _FullPath(const char * szPath){//std::string str(szPath);//如果只需要使用相对路径则使用此行替换下一行std::string str = FileUtils::getInstance()->fullPathForFilename(szPath);//补全成绝对路径return boost::locale::conv::between(str, "GBK", "UTF-8");//return FileUtils::getInstance()->fullPathForFilename(szPath);}

到此完成,可以使用中文路径了。。


0 0
原创粉丝点击