class Example extends Phaser.Scene { preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.spritesheet('explosion', 'assets/sprites/explosion.png', { frameWidth: 64, frameHeight: 64, endFrame: 23 }); this.load.spritesheet('balls', 'assets/sprites/balls.png', { frameWidth: 17, frameHeight: 17 }); } create () { const config = { key: 'explodeAnimation', frames: this.anims.generateFrameNumbers('explosion', { start: 0, end: 23, first: 23 }), frameRate: 20, repeat: -1 }; this.anims.create(config); this.add.sprite(400, 300, 'explosion').play('explodeAnimation'); this.add.sprite(400, 300, 'balls', 3); } } const config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', scene: Example }; const game = new Phaser.Game(config);
Scan to open on your mobile device
class Example extends Phaser.Scene { preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.spritesheet('explosion', 'assets/sprites/explosion.png', { frameWidth: 64, frameHeight: 64, endFrame: 23 }); this.load.spritesheet('balls', 'assets/sprites/balls.png', { frameWidth: 17, frameHeight: 17 }); } create () { const config = { key: 'explodeAnimation', frames: this.anims.generateFrameNumbers('explosion', { start: 0, end: 23, first: 23 }), frameRate: 20, repeat: -1 }; this.anims.create(config); this.add.sprite(400, 300, 'explosion').play('explodeAnimation'); this.add.sprite(400, 300, 'balls', 3); } } const config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', scene: Example }; const game = new Phaser.Game(config);