iOS: Get data from file failed

Hi everyone,

I got error “Cocos2d: Get data from file(splash_scene/splash.png) failed!” when I ran my iOS cocos2d-x project on Simulator. Here is my code:

// in AppDelegate.cpp
vector searchPath;
searchPath.push_back(“phone”);
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);

// in Splash Scene
CCSprite *splashSprite = CCSprite::create(“splash_scene/splash.png”); -->crash here

My resources organised:

  • Resources
    • splash_scene
      • splash.png
    • phone

Please help to to fix it in case I don’t want to change current organization of resources. Thanks.

Hi,
Maybe you should get the searchPath using the method setSearchPaths from CCFileUtils first and the path you are to push into the searchPath would better be an absolute path.Good luck!

Hi skychongrichie,

Thanks for your advice. It’s useful for me.