if resourcePath is ./res, when call the function with “myplist.list”
the above so-called FULL path should be “./res/myplist.list” and “./res/myplist.png”
now, the bug <pre>CCTexture2DpTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str());
\*
CCTextureCache::addImage can only use relative path,
the so-called FULL path was be regarded as a relative path,
so app prompt: “./res/./res/myplist.png” cannot found.
Mark. May have problem on win32 & iphone.
I have the phobia of dealing with string Bin will take this case tomorrow.
A pull request to github repo will be appreciated!
@XuDong Zhai,
I’m sorry that I could’t understand what’s your mean with my resourcePath is not empty and it is a relative path like “./res/”.
How did you set “./res/” into the engine?
By the way, can you simply tell me how to reproduce the probelm? Such like this:
I encounter the problem on XXX platform.
My code is: XXXXXXXXXXXXXXXXXXXXXXXXX
My resource files path is : XXXXXXXXXXXXXXXXXX
Sample codes of [win32] project ( but not only in [win32] )
see here:
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
pDirector->setProjection(kCCDirectorProjection2D);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
CCScene *pScene = SceneManager::sceneSandbox();
pDirector->runWithScene(pScene);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
{
const char* paths[] = { "./res/", "../res/" };
for(int i=0; i
when CCFileUtils::setRelativePath(“./res”)
and then CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(“FILENAME.plist”)
program throw: ./res/./res/FILENAME.png not found (should be ./res/FILENAME.plist )
when CCFileUtils::setRelativePath(“…/res”)
program ran ok, because the PNG filename is …/res/…/res/FILENAME.png equals to …/res/FILENAME.png
First, the parameter of method CCFileUtils::setResourcePath() must be absolute path. You can see this information from the comments in the source:cocos2dx/platform/CCFileUtils.h:
/**
@brief Set the ResourcePath,we will find resource in this path
@param pszResourcePath The absolute resource path
*/
static void setResourcePath(const char *pszResourcePath);
Second, the method CCFileUtils::setRelativePath() is only implemented on android. You also can see this information from the comments in the source:cocos2dx/platform/CCFileUtils.h: