Camera Blur Shader
Demonstrates how to apply a built-in blur filter to a specific camera and use camera ignore lists to keep certain game objects sharp.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('volcano', 'assets/pics/bw-face.png');
this.load.image('hotdog', 'assets/sprites/hotdog.png');
}
create ()
{
const volcano = this.add.image(400, 300, 'volcano').setAlpha(0.5);
const hotdog = this.add.image(400, 300, 'hotdog').setScrollFactor(0);
this.cameras.main.filters.internal.addBlur();
const extracam = this.cameras.add();
this.cameras.main.ignore(hotdog);
extracam.ignore(volcano);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
parent: 'game-container',
width: 800,
height: 600,
backgroundColor: '#000000',
scene: Example
};
const game = new Phaser.Game(config);