Cocos2dx3.2 audio cannot be played when SimpleAudioEngine is used (Chinese Path Problem)
Cocos2dx windows development is really a lot of twists and turns. Recently, I encountered the problem of playing sound in vs2013 debugging status, but not in debugging status.
I followed a lot of code and found that it was because of the Chinese path. So locate the problem and immediately fix it.
First, find the SimpleAudioEngine. cpp file in the libAudio project.
Find the following code:
//////////////////////////////////////////////////////////////////////////// static function//////////////////////////////////////////////////////////////////////////static std::string _FullPath(const char * szPath){ return FileUtils::getInstance()->fullPathForFilename(szPath);}
Modify as follows (I use boost for transcoding)
//////////////////////////////////////// /// // Static function // //////////////////////////////////////// /// // static std:: string _ FullPath (const char * szPath) {// std: string str (szPath); // If you only need to use a relative path, use this line to replace the next row of std :: string str = FileUtils: getInstance ()-> fullPathForFilename (szPath); // fill in the absolute path return boost: locale: conv: between (str, "GBK ", "UTF-8"); // return FileUtils: getInstance ()-> fullPathForFilename (szPath );}
Now, you can use the Chinese path ..