File Complete Event with Key
Learn how to use specific file completion events to trigger actions as soon as a particular asset finishes loading, using the 'filecomplete-type-key' event string.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('taikodrummaster', 'assets/pics/taikodrummaster.jpg');
this.load.image('sukasuka-chtholly', 'assets/pics/sukasuka-chtholly.png');
this.load.on('filecomplete-image-taikodrummaster', this.addImage, this);
}
addImage (key, file)
{
this.add.image(400, 300, key);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game-container',
pixelArt: true,
scene: Example
};
const game = new Phaser.Game(config);