Hello ,
I’m currently trying to construct coloring app that uses the predefined Graphics Api … the problem I’m facing is a strange behavior in the simulator and browser WebGL mode … while it’s working with a little bit of lag in the canvas mode in browser
this is the strange behavior
and here is the code written with the help of @PZsolt27 … Thank you very Much
if (this.gfxTarget !== null) {
this.gfxTarget.node.on(cc.Node.EventType.TOUCH_START, function (event) {
this.lastPos = event.touch.getLocation();
}, this);
this.gfxTarget.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
var g = this.gfxTarget;
g.lineWidth = 20;
g.lineCap = cc.Graphics.LineCap.ROUND;
g.lineJoin = cc.Graphics.LineCap.ROUND;
g.fillColor = this.currentColor;
g.strokeColor = this.currentColor;
var delta = event.touch.getDelta();
g.moveTo(this.lastPos.x, this.lastPos.y);
g.lineTo(this.lastPos.x + delta.x, this.lastPos.y + delta.y);
g.close();
g.stroke();
g.fill();
this.lastPos = event.touch.getLocation(); }, this); }
the problem actually recoloring the previous drawn line segments …
Hope someone can help
Thanks
Regards
Abulbisht