如何在 Cocos2d-x 中检测我是否需要使用 UHD、HD 或 SD

How to detect whether I need to use UHD, HD or SD in Cocos2d-x

我正在用 Cocos2d-x C++ 制作平台视频游戏。

我想做的事情真的很简单,但我在互联网上找到的所有东西要么不起作用,要么是针对另一种编程语言的,比如 Objective-C。

我有 1 个 spritesheet,有 3 个版本:一个是 UHD,另一个是 HD,最后一个是 SD.

我只需要知道如何告诉程序它应该使用什么资源。

我试过使用这个:

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");
}

但它只是 returns winSize 对象内存地址,因此无法使用它。我只需要看看屏幕分辨率是多少,然后设置我需要的图形类型即可。

抱歉,如果这是一个非常愚蠢的问题,我是 C++ 的新手,我还没有找到任何关于这个的东西。

谢谢

const Size& getWinSize ( ) const

returns the size of the OpenGL view in points.

来自 https://cocos2d-x.org/reference/native-cpp/V3.0alpha0/d7/df3/classcocos2d_1_1_director.html#aa841a76e9016679ff92bc053e1a41718

尺寸:https://cocos2d-x.org/reference/native-cpp/V3.0alpha0/d0/d8c/classcocos2d_1_1_size.html

所以我想,是这样的吗?

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
}