0

暗い背景画像をマスキングする四角形で領域を強調表示したい。マスク テクスチャは次のとおりです。

レンダリング結果は次のとおりです。

しかし、それは私が望むものではありません。このようにする必要があります(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);
4

1 に答える 1

1

あなたが持っているすべての制約を理解しているわけではありませんが、おそらくこれが役に立ちます。

私が理解していることから、ぼやけた領域が重なっている場所で問題が発生しています。したがって、ぼやけた領域が重ならないようにする必要があります。スプライトのみをレンダリングする場合は、単一のスプライトをさまざまなセクションに分割できます。

+-+----+-+ 
|a|  b |c|
+-+----+-+
| |    | |
|d|  e |f|
| |    | |
| |    | |
+-+----+-+ 
|g|  h |i|
+-+----+-+ 

次に、必要な場合にのみ各セクションをレンダリングします。

+-+----+----+-+ 
|a|  b |  b |c|
+-+----+----+-+
| |    |    | |
|d|  e |  e |f|
| |    |    | |
| |    |    | |
+-+----+----+-+ 
|g|  h |  h |i|
+-+----+----+-+ 

これが理にかなっており、役立つことを願っています。

于 2012-09-08T15:18:45.293 に答える