Javascript 设置相量器3中快照的位置

Javascript 设置相量器3中快照的位置,javascript,phaser-framework,Javascript,Phaser Framework,我正在使用,需要在预定义位置显示快照。当前,每个快照都会显示在主体下方,带有document.body.appendChild(图像) 我尝试了this.add.sprite(0,0,image).setOrigin(0.5,0)但它返回一个错误: 未捕获的TypeError:无法读取null的属性“add” 代码: 我将在正文末尾附加图像的部分保留在中,但可以根据需要进行编辑 var snapshot var lastpointer = {x: 100, y: 100} this.input

我正在使用,需要在预定义位置显示快照。当前,每个快照都会显示在主体下方,带有
document.body.appendChild(图像)

我尝试了
this.add.sprite(0,0,image).setOrigin(0.5,0)但它返回一个错误:

未捕获的TypeError:无法读取null的属性“add”

代码:


我将在正文末尾附加图像的部分保留在中,但可以根据需要进行编辑

var snapshot
var lastpointer = {x: 100, y: 100} 
this.input.on('pointerdown', (pointer) => {
    var textureManager = this.textures;
    this.game.renderer.snapshotArea(pointer.x, pointer.y, 128, 128, (image) => {
        lastpointer.x = pointer.x
        lastpointer.y = pointer.y
        document.body.appendChild(image);
       
        if (textureManager.exists('area'))
        {
            textureManager.remove('area');
        }

        textureManager.addImage('area', image);

        particles.setTexture('area');

        // Add the snapshot to the texture cache
        if (textureManager.exists('snapshot'))
        {
            textureManager.remove('snapshot');
            snapshot.destroy();
            snapshot = null;
        }
        textureManager.addBase64('snapshot', image.src);
    });

}, this);

// When the snapshot is actually loaded, add it to the pointer coordinates (or simply fixed ones)
this.textures.on('addtexture', function (texture) {
    if('snapshot' === texture) {
        snapshot = this.add.image(lastpointer.x, lastpointer.y, 'snapshot');
    }
}, this);
var snapshot
var lastpointer = {x: 100, y: 100} 
this.input.on('pointerdown', (pointer) => {
    var textureManager = this.textures;
    this.game.renderer.snapshotArea(pointer.x, pointer.y, 128, 128, (image) => {
        lastpointer.x = pointer.x
        lastpointer.y = pointer.y
        document.body.appendChild(image);
       
        if (textureManager.exists('area'))
        {
            textureManager.remove('area');
        }

        textureManager.addImage('area', image);

        particles.setTexture('area');

        // Add the snapshot to the texture cache
        if (textureManager.exists('snapshot'))
        {
            textureManager.remove('snapshot');
            snapshot.destroy();
            snapshot = null;
        }
        textureManager.addBase64('snapshot', image.src);
    });

}, this);

// When the snapshot is actually loaded, add it to the pointer coordinates (or simply fixed ones)
this.textures.on('addtexture', function (texture) {
    if('snapshot' === texture) {
        snapshot = this.add.image(lastpointer.x, lastpointer.y, 'snapshot');
    }
}, this);