Cocos2d iphone Cocos2d 2.1 AWTextureFilter仅模糊部分纹理

Cocos2d iphone Cocos2d 2.1 AWTextureFilter仅模糊部分纹理,cocos2d-iphone,blur,Cocos2d Iphone,Blur,我使用CoCoS2D2.0和AWTextureFilter。我需要模糊纹理。这是我的密码: //Create mutable texture CCTexture2DMutable *texture = [[CCTexture2DMutable alloc] initWithCGImage:[UIImage imageNamed:@"image.png"].CGImage resolutionType:kCCResolutionUnknown]; //Apply blur to the muta

我使用CoCoS2D2.0和AWTextureFilter。我需要模糊纹理。这是我的密码:

//Create mutable texture
CCTexture2DMutable *texture = [[CCTexture2DMutable alloc] initWithCGImage:[UIImage imageNamed:@"image.png"].CGImage resolutionType:kCCResolutionUnknown];

//Apply blur to the mutable texture
[AWTextureFilter blur:texture radius:10 rect:CGRectMake(0, 0, texture.contentSize.width, texture.contentSize.height)];

//Create sprites to show the textures
CCSprite *sprite = [CCSprite spriteWithTexture:texture];
sprite.position = ccp(winSize.width/2, winSize.height/2);
[layer addChild:sprite];
但结果我得到了只有部分模糊的精灵(截图):


为什么会这样?

我猜您必须将其与内容比例因子相乘,因为纹理内容大小以点为单位,而不是以像素为单位

CGSize size = texture.contentSize;
CGRect rect = CGRectMake(0, 0, 
                         size.width * CC_CONTENT_SCALE_FACTOR(), 
                         size.height * CC_CONTENT_SCALE_FACTOR());
[AWTextureFilter blur:texture radius:10 rect:rect];