Single Alpha
Demonstrates how to set the transparency level of a single image game object using the setAlpha method.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('face', 'assets/pics/bw-face.png');
}
create ()
{
const image = this.add.image(400, 300, 'face');
image.setAlpha(0.2);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
parent: 'game-container',
width: 800,
height: 600,
backgroundColor: '#7d2d2d',
scene: Example
};
const game = new Phaser.Game(config);