I'm making a platformer videogame in Cocos2d-x C++.
What I want to do is really easy but everything I have found on the internet either doesn't work or it's for another programming language like Objective-C.
I have 1 spritesheet with 3 versions: one is UHD, other is HD and the last one is SD.
I just need to know how to tell the program what resources it should use.
I've tried to use this:
Director::getInstance()->getVisibleSize();
auto winSize = Director::getInstance()->getWinSize(); //gets window size (pretty obvious, isn't it?)
if (&winSize == "2048x1536") { //The device uses UHD graphics
FileUtils::getInstance()->addSearchResolutionsOrder("UHD");
} else if (&winSize == "1024x768") { //The device uses HD graphics
FileUtils::getInstance()->addSearchResolutionsOrder("HD");
} else { //any other type of resolution -> asumes it is SD
FileUtils::getInstance()->addSearchResolutionsOrder("SD");
}
But it just returns the winSize object memory address so it is impossible to work with it. I just need to see what the screen resolution is and then set the type of graphics I need.
Sorry if this is a really stupid question, I'm new to C++ and I haven't found anything on this.
Thank you
const Size& getWinSize ( ) const
returns the size of the OpenGL view in points.
with size : https://cocos2d-x.org/reference/native-cpp/V3.0alpha0/d0/d8c/classcocos2d_1_1_size.html
So I guess, something like this?
auto winSize = Director::getInstance()->getWinSize(); //gets window size (pretty obvious, isn't it?)
if (winSize.width == 2048 and winSize.height == 1536 ) {
//The device uses HDR graphics
}