Bottom Alpha Gradient
Demonstrates how to apply a transparency gradient to an image by setting individual alpha values for its top and bottom corners.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('turkey', 'assets/pics/turkey-1985086.jpg');
this.load.image('face', 'assets/pics/bw-face.png');
}
create ()
{
const face = this.add.image(400, 300, 'face');
const sea = this.add.image(400, 300, 'turkey');
// top left, top right, bottom left, bottom right
sea.setAlpha(1, 1, 0, 0);
}
}
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);