我的平台是cocos2D V3.x和iOS。
我正在使用CC_CONTENT_SCALE_FACTOR()函数追加检测设备要求并相应地应用前缀但显示
不推荐使用cc_content_scale_factor()。
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
lstrNameToReturn = [lstrNameToReturn stringByAppendingString:@"-ipadhd"];
else
lstrNameToReturn = [lstrNameToReturn stringByAppendingString:@"-ipad"];
}
else
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
lstrNameToReturn = [lstrNameToReturn stringByAppendingString:@"-hd"];
else
lstrNameToReturn = lstrNameToReturn;
}
/** @def CC_CONTENT_SCALE_FACTOR
Factor relating pixel to point coordinates.
*/
extern CGFloat __ccContentScaleFactor;
/// Deprecated in favor of using CCDirector.contentScaleFactor or CCTexture2D.contentScale depending on usage.
static inline CGFloat DEPRECATED_ATTRIBUTE
CC_CONTENT_SCALE_FACTOR()
{
return __ccContentScaleFactor;
}
答案 0 :(得分:1)
这应该有效:
if (CCDirector.contentScaleFactor == 2) {
...
}