class Example extends Phaser.Scene { controls; preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.image('tiles', 'assets/tilemaps/iso/tilesets/tileset.png'); this.load.tilemapTiledJSON('map', 'assets/tilemaps/iso/hexagonal.json'); } create () { const map = this.add.tilemap('map'); const tileset = map.addTilesetImage('tileset', 'tiles'); map.createLayer('Calque 1', tileset); const cursors = this.input.keyboard.createCursorKeys(); this.cameras.main.setZoom(2); this.cameras.main.centerOn(200, 100); const controlConfig = { camera: this.cameras.main, left: cursors.left, right: cursors.right, up: cursors.up, down: cursors.down, acceleration: 0.02, drag: 0.0005, maxSpeed: 0.7 }; this.controls = new Phaser.Cameras.Controls.SmoothedKeyControl(controlConfig); } update (time, delta) { this.controls.update(delta); } } const config = { type: Phaser.AUTO, width: 800, height: 600, backgroundColor: '#2d2d2d', parent: 'phaser-example', pixelArt: true, scene: Example }; const game = new Phaser.Game(config);
Scan to open on your mobile device
class Example extends Phaser.Scene { controls; preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.image('tiles', 'assets/tilemaps/iso/tilesets/tileset.png'); this.load.tilemapTiledJSON('map', 'assets/tilemaps/iso/hexagonal.json'); } create () { const map = this.add.tilemap('map'); const tileset = map.addTilesetImage('tileset', 'tiles'); map.createLayer('Calque 1', tileset); const cursors = this.input.keyboard.createCursorKeys(); this.cameras.main.setZoom(2); this.cameras.main.centerOn(200, 100); const controlConfig = { camera: this.cameras.main, left: cursors.left, right: cursors.right, up: cursors.up, down: cursors.down, acceleration: 0.02, drag: 0.0005, maxSpeed: 0.7 }; this.controls = new Phaser.Cameras.Controls.SmoothedKeyControl(controlConfig); } update (time, delta) { this.controls.update(delta); } } const config = { type: Phaser.AUTO, width: 800, height: 600, backgroundColor: '#2d2d2d', parent: 'phaser-example', pixelArt: true, scene: Example }; const game = new Phaser.Game(config);