2

男性が歩いているアニメーションがあります。背景画像にはいくつかの木が含まれています。私はそれらの木のマスクを持っていて、それを男性の上に適用したいので、男性が木の後ろを歩いているように見えます.

これは私のコードです:

CCRenderTexture * rt = [CCRenderTexture 
                        renderTextureWithWidth:maskSprite.contentSizeInPixels.width 
                        height:maskSprite.contentSizeInPixels.height];
rt.position = ccp(maskSprite.contentSize.width/2, maskSprite.contentSize.height/2);
[rt.sprite setBlendFunc: (ccBlendFunc) { GL_ONE_MINUS_SRC_ALPHA, GL_ZERO }];
[rt beginWithClear:0.0f g:0.0f b:0.0f a:1.0f];
[walkingManSprite visit];
[rt end];
[maskSprite setBlendFunc: (ccBlendFunc) { GL_ZERO, GL_ONE_MINUS_SRC_ALPHA }];
[rt beginWithClear:0.0f g:0.0f b:0.0f a:1.0f];
[maskSprite visit];    
[rt end];

CCSprite *retval = [CCSprite spriteWithTexture:rt.sprite.texture];
retval.flipY = YES;
return retval;   

その結果、男は木の後ろを歩いていますが、私のマスクは背景の上に黒い影として表示されています. マスクを表示せずにアニメーションに適用するにはどうすればよいですか?

4

0 に答える 0