0
我正在尝试在iOS应用程序的iPad应用程序中创建绘画功能。我已经设法让颜色通过触摸出现,但我想重新创建photoshop的多功能性,以便底层的黑白图像继续显示颜色。我开始以不透明的方式做到这一点,但是在同一个地点进行会导致它最终被移除。我正在使用cocos2d,这是示例代码。在绘画中创建多重效果iPad应用程序
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];
我曾尝试在画笔上使用不同的混合功能,但没有设法创建我想要的外观。直接在背景上添加一个精灵及其混纺功能设定为
[sprite setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }];
当我没有得到正确的效果,但是当我尝试使用这种混合功能上刷什么出现在屏幕上。
感谢 伊恩
嗨Minthos,谢谢你的回复。我尝试了不同的选项,但是我一直无法得到这个工作。你可以提供一些示例代码为cocos2d来实现这一目标吗?如果我无法实现这个目标,有什么方法可以阻止不透明度的增加?所以如果我将不透明度设置为100,那么无论用户使用了多少次,它都会保持不变。 – sparkdoo