Save canvas using phaser3

How to take canvas screenshot image and store on device using phaser3?

if anyone knows please help me.

thanks in advance

http://labs.phaser.io/index.html?dir=snapshot/

Hi @samme ,
thanks for your reply,i want to store screenshot to my local device.

http://labs.phaser.io/index.html?dir=snapshot/

it takes screeshot but doesn’t store in local.can you show any example to do.

Finally i got a result,

This is my code, add inside a button pointer down function

 var canvas;

            function exportCanvasAsPNG(id, fileName, dataUrl) {
                var canvasElement = document.getElementById(id);
                var MIME_TYPE = "image/png";
                var imgURL = dataUrl;
                var dlLink = document.createElement('a');
                dlLink.download = fileName;
                dlLink.href = imgURL;
                dlLink.dataset.downloadurl = [MIME_TYPE, dlLink.download, dlLink.href].join(':');
                document.body.appendChild(dlLink);
                dlLink.click();
                document.body.removeChild(dlLink);
            }

            game.renderer.snapshot(function (image) {                
                exportCanvasAsPNG(canvas, 'snapshot', image.src);
            });
1 Like

What should be inside canvas element, not sure?