Ios 在iPad应用程序中创建多重效果

Ios 在iPad应用程序中创建多重效果,ios,opengl-es,cocos2d-iphone,Ios,Opengl Es,Cocos2d Iphone,我正在尝试在iOS版iPad应用程序中创建一个绘画功能。我已经设法让颜色通过触摸显示出来,但我想重新创建photoshop的倍增功能,以便底层黑白图像继续通过颜色显示出来。我开始做它的不透明性,但在同一个点上走会导致它最终被删除。我正在使用cocos2d,这是示例代码 in header CCSprite *background; CCRenderTexture *target; CCSprite *brush; in init method: background = [CCSprite s

我正在尝试在iOS版iPad应用程序中创建一个绘画功能。我已经设法让颜色通过触摸显示出来,但我想重新创建photoshop的倍增功能,以便底层黑白图像继续通过颜色显示出来。我开始做它的不透明性,但在同一个点上走会导致它最终被删除。我正在使用cocos2d,这是示例代码

in header
CCSprite *background;
CCRenderTexture *target;
CCSprite *brush;

in init method:
background = [CCSprite spriteWithFile:@"background.png"];
background.position = ccp(self.size.width/2, self.size.height/2);
[self addChild: background z:-1];
target = [[CCRenderTexture alloc] initWithWidth:self.size.width height:self.size.height pixelFormat:kCCTexture2DPixelFormat_RGBA8888];
[target setPosition:ccp(self.size.width/2, self.size.height/2)];
brush = [[CCSprite spriteWithSpriteFrameName:@"brush_spot.png"] retain];
[brush setColor:ccRED];

in -(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event method:
[target begin];
[brush setPosition:<CALCULATED POSITION>];
[brush visit];
[target end];
但当我尝试在画笔上使用此混合功能时,屏幕上没有显示任何内容

谢谢
Iain

混合函数将顶部的内容与后面的内容混合在一起。渲染到纹理时,将与该纹理的消隐对象混合。。我猜这是阿尔法0。因此,您应该使用不透明度绘制纹理


使用颜色填充纹理并将其附加到精灵后,可以再次渲染该纹理并将其与背景精灵混合。然后您可以使用乘法进行混合。

您好,谢谢您的回复。我尝试了不同的选择,但我没有能够让这项工作。您能为cocos2d提供一些示例代码来实现这一点吗?如果我不能让它工作,有没有办法阻止不透明度的增加?因此,如果我将不透明度设置为100,那么无论用户经过它多少次,它都将保持不变?
[sprite setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }];