Reveal Right to Left
Demonstrates a right-to-left wipe transition effect on a sprite using the wipe filter and a tween to control the progress property.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('pyramid', 'assets/sprites/pyramid.png');
this.load.image('bg', 'assets/skies/space4.png');
}
create ()
{
this.add.image(400, 300, 'bg');
const sprite = this.add.image(400, 300, 'pyramid');
const fx = sprite.enableFilters().filters.internal.addWipe(0.1, 1, 0, 1);
this.tweens.add({
targets: fx,
progress: 1,
repeatDelay: 1000,
hold: 1000,
yoyo: true,
repeat: -1,
duration: 2000
});
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#0a0067',
parent: 'game-container',
scene: Example
};
let game = new Phaser.Game(config);