I am developing a paint app. I want to make basic brush and erase. I tried blend mode drawNode.setBlendFunc(gl.ZERO,gl.ONE_MINUS_SRC_ALPHA);
for eraser but it is not working. Are there anbody help me? İf there is anyway to develop eraser please tell me
erase.setBlendFunc( cc.ZERO, cc.ONE_MINUS_SRC_ALPHA );
works for me.
Thanks for everyone. Joseph’s example is perfect
Any idea how to do this in Cocos Creator?
Looks like RenderTexture isn’t part of cocos creator.
currently I have this code in creator’s canvas onLoad Function…
It draws the brush fine and follows the touch movement, now if I can just get it to interact with a sprite to erase it’s pixels…
var brush = new cc.Node('brush01');
var sprite = brush.addComponent(cc.Sprite);
sprite.spriteFrame = this.brush;
sprite.srcBlendFactor = cc.BlendFunc.BlendFactor.ZERO;
sprite.dstBlendFactor = cc.BlendFunc.BlendFactor.ONE_MINUS_SRC_ALPHA;
brush.parent = this.node.parent;
brush.setPosition(0,0);
brush.setScale(0.1 ,0.1 );
brush.opacity = 255;
this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
//eraseAtPoint(event.getLocation(), brush);
//brush.setPosition(event.getLocation());
});
this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
eraseAtPoint(event.getLocation(), brush);
//brush.setPosition(event.getLocation());
});
this.node.on(cc.Node.EventType.TOUCH_END, function (event) {
brush.setPosition(-100,-100);
})
var eraseAtPoint = function(pt,brush){
brush.setPosition(pt);
}
Let me ask someone to look at your question.
I’m not sure and it is the weekend for the engineering team, so I’d assume they will answer this soon.
Alright I’ll look forward to hearing back from them. I’d like to use the latest iteration of cocos (‘cocos creator’) if possible.
Never heard back on this. I got it to work in cocos2d-x but not cocos creator… Any update on blend modes in cocos creator?
@slackmoehrleany update?
Is there any way we can found the erase percentage? I mean how much texturein term of percenetage still remaining ?