如何替换已弃用的 cc_content_scale_factor()

how to replace the deprecated cc_content_scale_factor()

我的平台是cocos2DV3.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;
}

这应该有效:

if (CCDirector.contentScaleFactor == 2) {
    ...
}