I am making different images for iphone and ipad. I have two different images of background but I kept the name of the file bg1.png for both. I put the ipad resolution file in ipad folder and iphone resolution file in iphone4 folder in my resource. My mode is landscape so the height becomes width and width is height
in my AppDelegate.cpp in didfinishlaunch function I put the following code
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
std::vector<std::string> searchPath;
CCSize winSize=CCDirector::sharedDirector()->getWinSize();
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);
if(pDirector->getWinSize().height>=768)
{
CCLOG("if width = %f",pDirector->getWinSize().height);
searchPath.push_back("ipad");
// CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
}
else if(pDirector->getWinSize().height<768)
{
CCLOG("else width = %f",pDirector->getWinSize().height);
searchPath.push_back("iphone4");
}
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
Every time it is coming in the if block but every alternate time it shows the different images. Suppose if I run for the first time it shows the ipad image. Then i stop the build and re run the code, then it shows iphone image. But I am using the Ipad simulator in both the case. Is anything wrong with the code?