There are 2 canvases on page:
- with Phaser game attached
- another controlled by external scripts
I need to capture image from second canvas and put as sprite in first one.
This code perfectly works with Phaser 2.6
this.sprite.loadTexture(PIXI.Texture.fromCanvas(secondCanvasEl, PIXI.scaleModes.DEFAULT));
Any suggestions how to do that with Phaser v3.55 ?
samme
2
const canvasTexture = this.textures.addCanvas('secondCanvas', secondCanvasEl);
this.add.image(x, y, canvasTexture);
@samme It will fails if second canvas using webgl. CanvasTexture doesn’t support:
CanvasTexture (manager, key, source, width, height)
...
this.context = this.canvas.getContext('2d');
How to grab image from webgl canvas ?
samme
4
Phaser.Renderer.Snapshot.WebGL(secondCanvasEl, {
callback: (image) => {
this.textures.addImage('secondCanvas', image);
this.add.image(x, y, 'secondCanvas');
},
});