Multi-resolution problem.

Hello there,

I try to create cocos2d-x project that support multi resolution for ipad, iphone. but it’s not working as expected.
For example : it shows images in ipad folder instead of iphone folder when i run it on iPhone Simulator.

this is my code in AppDelegate::applicationDidFinishLaunching

CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    // multi resolution support
    pDirector->setOpenGLView(pEGLView);
    CCSize frame_size = pEGLView->getFrameSize();
    std::vector<std::string> res_dir_orders;
    
    CCSize designSize = CCSizeMake(480, 320);
    CCSize resourceSize;
    
    if (2048 == frame_size.width || 2048 == frame_size.height)
    {
        res_dir_orders.push_back("ipadhd");
        resourceSize = CCSizeMake(2048, 1536);
        designSize = CCSizeMake(2048, 1536);
    }
    else if (1024 == frame_size.width || 1024 == frame_size.height)
    {
        res_dir_orders.push_back("ipad");
        resourceSize = CCSizeMake(1024, 768);
        designSize = CCSizeMake(1024, 768);
    }
    else if (1136 == frame_size.width || 1136 == frame_size.height)
    {
        res_dir_orders.push_back("iphonehd5");
        resourceSize = CCSizeMake(1136, 640);
        designSize = CCSizeMake(1136, 640);
    }
    else if (960 == frame_size.width || 960 == frame_size.height)
    {
        res_dir_orders.push_back("iphonehd");
        resourceSize = CCSizeMake(960, 640);
        designSize = CCSizeMake(960, 640);
    }
    else
    {
        res_dir_orders.push_back("iphone");
        resourceSize = CCSizeMake(480, 320);
        designSize = CCSizeMake(480, 320);
    }
    CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(res_dir_orders);
    
    pDirector->setContentScaleFactor(resourceSize.width / designSize.width);
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionFixedWidth);

    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

What’s the engine version?
cocos2d.x.version: 2.2.3

Thanks for reading.

I read the code carefully, and there is nothing wrong with it (except I would use some comparison instead of equals sign to support other resolutions, if you plan to support something else than iOS).

Just to be sure, did you double-check your assets and try to put totally different images with the same name in the different folders ?

The only significant difference with my code is that I use CCFileUtils::sharedFileUtils()->setSearchPaths() instead of CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(). I think I had problems with the latter, but don’t remember the specifics.

Attached file is my project structure.
i changed the code to using CCFileUtils::sharedFileUtils()->setSearchPaths() instead of CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(). It’s still not working as expected.

Note: my project is auto generated (by command line ./create_project.py -project Project -package com.CIMinuv.Project -language cpp) and i just changed AppDelegate.cpp file as above.