I'm using Xcode IDE and Cocos2dx for developing multi platform game. i have just started development and 'm stuccoed at one place. I want to change the resource folder in accordance to the size of the screen.
CCSize screenSize = pEGLView->getFrameSize();
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1024,
kResolutionExactFit);
if (screenSize.width > 768) {
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
pDirector->setContentScaleFactor(2);
} else {
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
pDirector->setContentScaleFactor(1);
}
but since the setResourceDirectory() is deprecated i can use any other method. I tried using setSearchPaths() but its giving errors. please let me know if anyone have the same thing working. Thanks in advance.
okay, since setDesignResolutionSize()
is deprecated we need to use setSearchPaths()
you can have something like this, Its working in my case:
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(768, 1024,
kResolutionExactFit);
std::vector<std::string> searchPaths;
if (screenSize.width > 768) {
searchPaths.push_back("hd");
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(2);
}else{
searchPaths.push_back("sd");
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With