如何替换已弃用的cc_content_scale_factor()

时间:2015-02-20 05:22:24

标签: ios cocos2d-iphone

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

1 个答案:

答案 0 :(得分:1)

这应该有效:

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