Frames From a Single Texture Atlas
Demonstrates how to load a single texture atlas and display multiple different images by referencing their individual frame names.
1024 × 768
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.atlas('atlas', 'assets/atlas/megaset-1.png', 'assets/atlas/megaset-1.json');
}
create ()
{
this.add.image(400, 200, 'atlas', 'titan-mech');
this.add.image(400, 400, 'atlas', 'ship');
this.add.image(400, 600, 'atlas', 'supercars-parsec');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);