Trimmed Frame from Texture Atlas
Demonstrates loading a texture atlas and displaying a specific frame that has been trimmed, illustrating how Phaser handles original source dimensions versus trimmed sizes.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.atlas('atlas', 'assets/atlas/megaset-2.png', 'assets/atlas/megaset-2.json');
}
create ()
{
const i = this.add.image(400, 300, 'atlas', 'hello');
console.log(i.width, i.height);
console.log(i.frame);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
parent: 'game-container',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);