I am trying to make a demo of the classic eraser effect with cocos2d-js 3.10 using RenderTexture.
The code is simple and it works fine:
var size = cc.winSize;
var Bg = new cc.Sprite("res/background.png");
Bg.setPosition(size.width / 2, size.height / 2);
this.addChild(Bg, -1);
this.pEraser = new cc.DrawNode();
this.pEraser.drawDot(cc.p(300, 300), 50, cc.color(255, 0, 255, 0));
this.pEraser.setBlendFunc(cc.GL_ONE_MINUS_SRC_ALPHA, cc.ZERO);
this.pEraser.retain();
this.pRTex = new cc.RenderTexture(size.width, size.height);
this.pRTex.setPosition(size.width / 2, size.height / 2);
this.addChild(this.pRTex);
var pBg = new cc.Sprite("res/foreground.png");
pBg.setPosition(size.width / 2, size.height / 2);
this.pRTex.begin();
pBg.visit();
this.pEraser.visit();
this.pRTex.end();
The only problem is, the DrawNode should be a “Circle” but it ends up in a “Square” shape :
The code is running in WEBGL mode.
BTW, I also tried drawPoly and it works OK …
Any suggestion will be appreciated, thanks 