I'm using this Phaser 3 example and I need to display the snapshot in a predefined position. Currently every snapshot gets displayed below the body with document.body.appendChild(image);
I tried this.add.sprite(0, 0, image).setOrigin(0.5,0); but it returns an error:
Uncaught TypeError: Cannot read property 'add' of null
Code:
this.input.on('pointerdown', function (pointer) {
var textureManager = this.textures;
this.game.renderer.snapshotArea(pointer.x, pointer.y, 128, 128, function (image)
{
document.body.appendChild(image);
if (textureManager.exists('area'))
{
textureManager.remove('area');
}
textureManager.addImage('area', image);
particles.setTexture('area');
});
}, this);