Loading a Base64 Image
Demonstrates how to load and display an image by passing a Base64 encoded string directly to the Phaser Loader instead of a file URL.
800 × 600
// #module
import { blockPNG } from '../../../assets/base64/block-image.js';
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('block', blockPNG);
}
create ()
{
this.add.image(400, 300, 'block');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);