Search code examples
eclipsecocos2d-x-2.x

Get data from file(image\splash.png) failed


I've been learning cocos2d-x by developing a flappy bird. The version is 2.2.3.

My program can run on VS. But when I build it in eclipse and install the apk to an android device, the App flash back and the logcat says: Get data from file(image\splash.png) failed.

I found the code in cpp file:

std::string splash_path = CCFileUtils::sharedFileUtils()->fullPathForFilename("image\\splash.png");
CCSprite *background = CCSprite::create(splash_path.c_str());

And all the images and sounds are in the assets folder.

Anyone can tell me how to solve this problem?

Thanks.


Solution

  • I have solved the problem by changing the code to:

    std::string splash_path = CCFileUtils::sharedFileUtils()->fullPathForFilename("image/splash.png");
    

    just replace the '\\' to '/'.