-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Description
Version
- Phaser Version: 3.55.2
- Operating system: doesn't matter
- Browser: doesn't matter
Description
Trying to get a snapshot from the container, when using Canvas Renderer. There seems a reference issue.
snapshotCanvas: function (canvas, callback, getPixel, x, y, width, height, type, encoderOptions)
{
if (getPixel === undefined) { getPixel = false; }
this.snapshotArea(x, y, width, height, callback, type, encoderOptions);
var state = this.snapshotState;
state.getPixel = getPixel;
CanvasSnapshot(this.canvas, state);
state.callback = null;
return this;
},
The function uses CanvasSnapshot(this.canvas, state);
but there is no this.canvas
property in there, there is canvas
argument, that I think might be there or this.gameCanvas
could be placed instead of this.canvas
.
Example Test Code
protected async generateImage(): Promise<
Phaser.Display.Color | HTMLImageElement
> {
return new Promise<Phaser.Display.Color | HTMLImageElement>((resolve) => {
const texture = this.add.renderTexture(
0,
0,
this.gameObject.width,
this.gameObject.height,
);
texture.draw(this.gameObject);
texture.snapshot(resolve, 'image/png', 1);
});
}
}
Additional Information
Metadata
Metadata
Assignees
Labels
No labels