Nine Slice with Texture Atlas
Demonstrates how to create Nine Slice Game Objects using frames loaded from a Texture Packer atlas.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.atlas('ui', 'assets/atlas/nine-slice.png', 'assets/atlas/nine-slice.json');
}
create ()
{
this.add.nineslice(400, 300, 'ui', 'blue-box', 600, 400);
this.add.nineslice(400, 300, 'ui', 'flectrum', 600);
this.add.nineslice(400, 300, 'ui', 'button-bg');
// this.add.nineslice(400, 300, 'ui', 'copy-that-floppy');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#000000',
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);