Cocos2d iphone 带遮罩的Cocos2d动画

Cocos2d iphone 带遮罩的Cocos2d动画,cocos2d-iphone,sprite,mask,sprite-sheet,Cocos2d Iphone,Sprite,Mask,Sprite Sheet,我有一个男人走路的动画。背景图像包含一些树。我有一个戴着那些树的面具,我想把它戴在那个人身上,这样看起来就像那个人走在树后面 这是我的代码: CCRenderTexture * rt = [CCRenderTexture renderTextureWithWidth:maskSprite.contentSizeInPixels.width height:maskSprite.contentSize

我有一个男人走路的动画。背景图像包含一些树。我有一个戴着那些树的面具,我想把它戴在那个人身上,这样看起来就像那个人走在树后面

这是我的代码:

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;   

结果是这个人走在树后面,但我的面具在背景上显示为黑色阴影。如何不显示遮罩而将其应用于动画

您可以尝试删除rt上的第二个“behinWithClear”吗?您可以尝试删除rt上的第二个“behinWithClear”吗?