Smooth Pixel Art Rendering
Demonstrates the use of the smoothPixelArt configuration property to enable anti-aliasing for textures while maintaining smooth edges during camera zooms and rotations.
800 × 600
class Example extends Phaser.Scene
{
image;
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('einstein', 'assets/pics/ra-einstein.png');
}
create ()
{
this.image = this.add.image(400, 300, 'einstein');
}
update ()
{
this.image.rotation += 0.01;
this.cameras.main.zoom = (2 + Math.sin(this.image.rotation)) * 2;
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'game-container',
scene: Example,
// Enable the following to see aliased pixel art:
// pixelArt: true,
// Enable the following to see anti-aliased pixel art:
smoothPixelArt: true
};
const game = new Phaser.Game(config);