const myCustomCanvas = document.createElement('canvas');
myCustomCanvas.id = 'myCustomCanvas';
myCustomCanvas.style = 'border: 8px solid green';
document.body.appendChild(myCustomCanvas);
// It's important to set the WebGL context values that Phaser needs:
const contextCreationConfig = {
alpha: false,
depth: false,
antialias: true,
premultipliedAlpha: true,
stencil: true,
preserveDrawingBuffer: false,
failIfMajorPerformanceCaveat: false,
powerPreference: 'default'
};
const myCustomContext = myCustomCanvas.getContext('webgl2', contextCreationConfig);
const config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 800,
height: 600,
canvas: myCustomCanvas,
context: myCustomContext,
scene: {
preload: preload,
create: create
}
};
const game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v355');
this.load.image('pic', 'assets/pics/baal-loader.png');
}
function create ()
{
this.add.image(400, 300, 'pic');
}
const myCustomCanvas = document.createElement('canvas');
myCustomCanvas.id = 'myCustomCanvas';
myCustomCanvas.style = 'border: 8px solid green';
document.body.appendChild(myCustomCanvas);
// It's important to set the WebGL context values that Phaser needs:
const contextCreationConfig = {
alpha: false,
depth: false,
antialias: true,
premultipliedAlpha: true,
stencil: true,
preserveDrawingBuffer: false,
failIfMajorPerformanceCaveat: false,
powerPreference: 'default'
};
const myCustomContext = myCustomCanvas.getContext('webgl2', contextCreationConfig);
const config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 800,
height: 600,
canvas: myCustomCanvas,
context: myCustomContext,
scene: {
preload: preload,
create: create
}
};
const game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v355');
this.load.image('pic', 'assets/pics/baal-loader.png');
}
function create ()
{
this.add.image(400, 300, 'pic');
}