1.setResourceDirectory
在最近更新的版本里,已经没有了setResourceDirectory,取而代之的是setSearchPaths
2.将string转换为 const* char
const * char c_str()
一个将string转换为 const* char的函数。
string的c_str()返回的指针是由string管理的。它的生命期是string对象的生命期。然后可以按C的方式使用这个指针,或把它的内容复制出来。
例如:
string s;
cin>>s;
const char *ch=s.c_str();
3.
关于cocos2d-x 2.14 删除fullPathFromRelativePath 的解决方法
参考发现网上的代码时发现
CCFileUtils::fullPathFromRelativePath("");
cocos2d::CCFileUtils" 没有成员 "fullPathFromRelativePath"
后来看帖有人提出2.x版本该方法不再是静态的故应使用
CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("");调用
但是依旧是上面的错误。突然想起最近使用
CCTextureCache::sharedTextureCache()->addImageAsync()时参数是相对路径
顾跟踪代码到CCTextureCache.cpp中发现以下代码段
看来这个方法真的是被取消了,故得到解决方案:
std::string pathKey = "test.xml";
pathKey = CCFileUtils::sharedFileUtils()->fullPathForFilename(pathKey.c_str());
TiXmlDocument* xmlDoc = new TiXmlDocument(pathKey.c_str());