这个问题一直没有解决,所以在此求解决方案
问题出现在android平台上调用cc.FileUtils:getInstance():setSearchPaths()函数,出现传入参数和getSearchPaths打印内容不一致(mac和iOS平台上没有问题),代码和打印结果如下:
lua层代码
logUtil: write( "+++++++setSearchPaths前的组数:+++++++" ) for _ , sp in ipairs(searchPaths) do logUtil: write(sp) end logUtil: write( "-----执行setSearchPaths-----" ) cc. FileUtils :getInstance () :setSearchPaths (searchPaths) logUtil: write( "*****setSearchPaths后的组数:*****" ) for _ , path in ipairs(cc. FileUtils :getInstance () :getSearchPaths () ) do if path ~= "" then logUtil: write(path.. ">>>>>>" ..string.format( "%s" , tostring(cc. FileUtils :getInstance () :isDirectoryExist (path)))) end end
打印结果:
2018 - 03 - 26 23 : 53 : 12 --->+++++++setSearchPaths前的组数:+++++++ 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/ 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/ 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/src/ 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/res/ 2018 - 03 - 26 23 : 53 : 12 --->assets/ 2018 - 03 - 26 23 : 53 : 12 --->assets /src/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/bgm/backgroundmusic/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/bgm/effectmusic/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/mahjong/voice/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/mahjong/voice/man/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/mahjong/voice/woman/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/ui/communal/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/ui/mahjong/hall/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/ui/mahjong/settings_panel/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/ui/mahjong/shop/ 2018 - 03 - 26 23 : 53 : 12 --->assets /res/mahjong/shaiziAnim/ 2018 - 03 - 26 23 : 53 : 12 --->-----执行setSearchPaths----- 2018 - 03 - 26 23 : 53 : 12 --->*****setSearchPaths后的组数:***** 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/ >>>>>> true 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/ >>>>>> true 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/res/ >>>>>> true 2018 - 03 - 26 23 : 53 : 12 ---> /data/data/com.cuocuo.majiang/files/new_version/assets/res/ >>>>>> true 2018 - 03 - 26 23 : 53 : 12 --->assets/>>>>>> true 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/bgm/backgroundmusic/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/bgm/effectmusic/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/mahjong/voice/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/mahjong/voice/man/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/mahjong/voice/woman/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ui/communal/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ui/mahjong/hall/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ui/mahjong/settings_panel/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/ui/mahjong/shop/ >>>>>> false 2018 - 03 - 26 23 : 53 : 13 --->assets /res/mahjong/shaiziAnim/ >>>>>> false
从日志中可以看到执行setSearchPaths函数以前是
.../data/data/com.cuocuo.majiang/files/new_version/assets/src//data/data/com.cuocuo.majiang/files/new_version/assets/res/... assets/src/assets/res/
执行setSearchPaths后变成了:
.../data/data/com.cuocuo.majiang/files/new_version/assets/res//data/data/com.cuocuo.majiang/files/new_version/assets/res/... assets/res/assets/res/
C++层的代码如下:
void FileUtils::setSearchPaths( const std :: vector < std :: string >& searchPaths) { bool existDefaultRootPath = false ; _fullPathCache.clear(); _searchPathArray.clear(); for ( const auto & iter : searchPaths) { std :: string prefix; std :: string path; if (!isAbsolutePath(iter)) { // Not an absolute path prefix = _defaultResRootPath; } path = prefix + (iter); if (path.length() > 0 && path[path.length()- 1 ] != '/' ) { path += "/" ; } if (!existDefaultRootPath && path == _defaultResRootPath) { existDefaultRootPath = true ; } _searchPathArray.push_back(path); } if (!existDefaultRootPath) { //CCLOG("Default root path doesn't exist, adding it."); _searchPathArray.push_back(_defaultResRootPath); } }
错误导致没法加载任何lua文件
@minggo @dumganhar @jare @panda
各位大神有没有好的解决思路?求解啊 求解 如果我解决了会在讨论出留下解决方案
最新回复 (0)