Hi all,
I am trying to erase an canvas texture by create a cirlce, but it only draw an circle object and don’t erase the canvas texture. Here is my code:
‘’’
this.textures1 = this.textures.get(‘canvastextures1’)
this.textures1.getContext()
this.textures1.globalCompositeOperation = “destination-out”
this.hole = this.add.graphics()
this.hole.fillStyle(0x000000, 0)
this.hole.beginPath()
this.hole.arc(420, 50, 180, 0, Math.PI * 2, false)
this.hole.closePath()
this.hole.fill()
this.textures1.globalCompositeOperation = “source-over”
this.textures1.refresh()
‘’’
Does anyone have any ideas? Thank you.
The objects are mixed up.
// CanvasTexture
this.textures1 = this.textures.get('canvastextures1');
// CanvasRenderingContext2D
var ctx = this.textures1.getContext();
ctx.globalCompositeOperation = 'destination-out';
ctx.beginPath();
ctx.arc(420, 50, 180, 0, Math.PI * 2, false);
ctx.closePath();
ctx.fill();
this.textures1.refresh();
1 Like