Question

I am facing this problem of random output of my application at each launch in xcode simulator. I am using xCode Version 4.6.3 . I tried and executed all the steps mentioned in here How to Empty Caches and Clean All Targets Xcode 4 but it didn't help. I am using different resources for different family of devices. (Basically I am making universal iOs app.). Please check below code which I am using in AppDelegate.cpp

CCSize screenSize = pEGLView->getFrameSize();

//set design size for iPad retina

CCSize designSize = CCSize(1536,2048); //1.33

float screenRatio = screenSize.height/screenSize.width;

std::vector<std::string> searchPaths;

if (screenSize.width > 768)
{
    searchPaths.push_back("ipadRetina");
}
else if (screenSize.width > 320)
{
    if (screenRatio == 1.5f) // && screenRatio < 1.775f)
    {
        searchPaths.push_back("iphoneRetina");
        designSize = CCSize(640,960);       
    }
    else if(screenRatio == 1.775f)
    {
        searchPaths.push_back("iphoneFive");
        designSize = CCSize(640,1136);
              }
    else
    {
        searchPaths.push_back("ipad");

    }
}
else
{
    searchPaths.push_back("iphone");
    designSize = CCSize(320,480);

}


CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll);
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(screenSize.height/designSize.height);

Output each time I'm getting is completely random.Sometimes images coming are with extra zoom, after that, if I close the project and rerun it, output (images) comes shrinked. On Next run it comes completely different than previous two outputs.

What I observed from above code is when I am trying to run application for ipadRetina it takes resources,sometimes from iphone folder,sometimes from ipadRetina folder.. but when I put the breakpoint,searchpath is set for ipadRetina folder.

Please help.

Was it helpful?

Solution 2

Although its not the answer but I could not find a way to add it as a comment. @nomannasim I think that should not be the problem , as Deva is maintaining different folders for different resolution devices and which folder is selected depends on the width and aspect ratio of the device on which app is running.So any how only one folder's path is going to be set in searchPath of CCFileUtils::sharedFileUtils(). So no confusion in picking up resources.

OTHER TIPS

Seems like there are multiple resources in your project tree with same name. Xcode is just getting confused when you refer an image named my-image.png and there are multiple images with that name in your project.

A good way to avoid this type of issues is to have unique resource names like:

game-image.png (for iPhone)
game-image-hd.png (for iPhone Retina)
game-image-ipad.png (for iPad)
game-image-ipad-hd.png (for iPad Retina)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top