std::string filePath = FileUtils::getInstance()->fullPathForFilename(fileName);@H_404_2@
XMLDocument *pDoc = new XMLDocument();@H_404_2@ XMLError errorId = pDoc->LoadFile(filePath.c_str());@H_404_2@ log("errorId %d",errorId);
fileName在Android下assets目录,以上代码errorId总为3 (找不到)
@H_404_2@
原因是FileUtils返回全路径并没做好android的适配。
@H_404_2@
可以这么绕开:
std::string content = FileUtils::getInstance()->getStringFromFile(fileName);@H_404_2@ XMLError errorId = pDoc->Parse(content.c_str());
这么返回就为0了(成功了)
原文链接:https://www.f2er.com/cocos2dx/340818.html