cocos2d-x-v3安卓平台tinyxml2读取xml出错

前端之家收集整理的这篇文章主要介绍了cocos2d-x-v3安卓平台tinyxml2读取xml出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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