Load XML Texture Atlas
Demonstrates how to load and display frames from a texture atlas that uses an XML data file for frame definitions.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.atlasXML('round', 'assets/atlas/round.png', 'assets/atlas/round.xml');
}
create ()
{
const atlasTexture = this.textures.get('round');
const frames = atlasTexture.getFrameNames();
for (let i = 0; i < frames.length; i++)
{
const x = Phaser.Math.Between(0, 800);
const y = Phaser.Math.Between(0, 600);
this.add.image(x, y, 'round', frames[i]);
}
}
}
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);