Load Unity Atlas
Demonstrates how to load and display textures from a spritesheet exported in the Unity atlas format using a PNG and its corresponding .meta file.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.unityAtlas('asteroids', 'assets/atlas/asteroids.png', 'assets/atlas/asteroids.png.meta');
}
create ()
{
this.add.image(200, 200, 'asteroids', 'asteroids_7');
this.add.image(400, 200, 'asteroids', 'asteroids_10');
this.add.image(600, 200, 'asteroids', 'asteroids_13');
this.add.image(200, 400, 'asteroids', 'asteroids_17');
this.add.image(400, 400, 'asteroids', 'asteroids_21');
this.add.image(600, 400, 'asteroids', 'asteroids_30');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
width: 800,
height: 600,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);