Image Alpha
Demonstrates how to change the transparency of an image by setting its alpha property.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('bunny', 'assets/sprites/bunny.png');
}
create ()
{
const bunny = this.add.image(400, 300, 'bunny');
bunny.alpha = 0.5;
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
parent: 'game-container',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);