Cocos2d-x 3.0 FileUtils on Mac OS X

Hi,

I am running the following code under Cocos2d-x 3.0

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview)
	{
        glview = GLView::create("My Game");
        director->setOpenGLView(glview);
    }
   
    auto fileUtils = FileUtils::getInstance();
    std::vector<std::string> searchPaths;
    searchPaths.push_back("Images");
    fileUtils->setSearchPaths(searchPaths);
    
	// Add configuration files for sprites and objects
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("sprites.plist","sprites.png");
	GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile("objects.plist");

    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    auto scene = GameLayer::createScene();

    // run
    director->runWithScene(scene);

    return true;
}

I tested this code with VS2012 and iOS. However, when I run this on Mac OS X I get the following error:

**
libpng warning: iCCP: known incorrect sRGB profile
cocos2d: cocos2d: fullPathForFilename: No file found at sprites.png. Possible missing file.
cocos2d: cocos2d: fullPathForFilename: No file found at sprites.png. Possible missing file.
cocos2d: cocos2d: fullPathForFilename: No file found at sprites.png. Possible missing file.
cocos2d: Get data from file(sprites.png) failed!
cocos2d: cocos2d: SpriteFrameCache: couldn’t load texture file. File not found sprites.png
cocos2d: cocos2d: fullPathForFilename: No file found at objects.plist. Possible missing file.
**

DO you have any idea of what I am doing wrong?

Thanks

1 Like

well, sprites.plist sprites.png, objects.plist need to be in your Resources/Images/ by what you have done above.
Works for me.

@slackmoehrle
The thing is that it works for iOS, Windows, but not for OS X. I am not sure if there is something to do with some configuration of Xcode

The files must be added to projects and to product build steps too. Please check your project and product settings to make sure all resource files are included in the final application.

I found the problem. At the File Inspector there is a property called Location. I have to check the Target Membership for the Mac project (/)

1 Like

similar problem fixed, thanks

Could you show me your solution? I am using cocos2d-x v3.6

1 Like

Thanks. In the file inspector, Target membership i had to check the desktop target. Only the iOS target was checked. :slight_smile: