暗い背景画像をマスキングする四角形で領域を強調表示したい。マスク テクスチャは次のとおりです。
レンダリング結果は次のとおりです。
しかし、それは私が望むものではありません。このようにする必要があります(ps写真):
背景テクスチャはフルスクリーンサイズのダークカラー写真です。
マスク テクスチャは 40 ピクセル サイズです。だから、レンダリング時に別の形になるように動かしたい。メジャー コード:
CCSprite *textureSprite=[CCSprite spriteWithFile:@"bg_blank_alpha.png"];
CCSprite *maskSprite=[CCSprite spriteWithFile:@"bg_box_futher.png"];
CCRenderTexture * rt = [CCRenderTexture renderTextureWithWidth:textureSprite.contentSizeInPixels.width height:textureSprite.contentSizeInPixels.height];
textureSprite.position = ccp(textureSprite.contentSize.width/2, textureSprite.contentSize.height/2);
[maskSprite setBlendFunc:(ccBlendFunc){GL_SRC_COLOR, GL_ZERO}];
[textureSprite setBlendFunc:(ccBlendFunc){GL_ONE_MINUS_DST_ALPHA, GL_ZERO}];
[rt begin];
maskSprite.position=ccp(160, 240);
[maskSprite visit];
maskSprite.position=ccp(200, 240);
[maskSprite visit];
[textureSprite visit];
[rt end];
CCSprite *retval = [CCSprite spriteWithTexture:rt.sprite.texture];
retval.flipY = YES;
[self addChild:retval];
retval.position=ccp(160,240);