Black background on loading Phaser

When my games load there is a flash of black as phaser loads.

This happens as the games initialize before the background color is set.

Is there any way of changing that?

2 Likes

I haven’t seen this before; how is your HTML body/canvas styled?

Mine started doing that as well but only after I set mode to use Phaser.Scale.Fit I assumed it had something to do with the display properties.

This happens because the default backgroundColor in the game config is black. You can fix this like so:

const config = {
  //...
  backgroundColor: 0xff0000,
  //...
}
let game = new Phaser.Game(config);

You can also make the canvas transparent (if you have background images or the like that you will use later) by doing:

const config = {
  //...
  transparent: true,
  //...
}
let game = new Phaser.Game(config);`
2 Likes