Hi!
getPathForFilename can’t find any file in directories added with CCFileUtils::addSearchResolutionsOrder when using multi-resolution. I use cocos2d-x 2.2.1.
My code to add a resolution order for high-definition (hd folder)
fileUtils.addSearchResolutionsOrder("hd");
pDirector->setContentScaleFactor(2.f);
Then I load the file (in Lua)
CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile('actions.plist')
I made some debug and could find out that the resolution order (hd) is concatenated to the filename (actions.plist) without any slash in between. Check line 3 in the log output below.
D/cocos2d-x debug info(24600): SEARCHING: actions.plist, hd, assets/
D/cocos2d-x debug info(24600): path= assets/hd file= actions.plist
D/cocos2d-x debug info(24600): File assets/hdactions.plist not found
The bug is fixed if I use getFullPathForDirectoryAndFilename from cocos2d-x 3.0 which include the required slash.
std::string CCFileUtils::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename)
{
std::string ret = strDirectory;
if (strDirectory.size() && strDirectory[strDirectory.size()-1] != '/'){
ret += '/';
}
ret += strFilename;
// if the file doesn't exist, return an empty string
if (!isFileExist(ret)) {
ret = "";
}
return ret;
Is there any issue using a hardcoded slash separator on other platform (i.e. windows)?
Thanks!