Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
class Example extends Phaser.Scene { layer; rt; preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.image('tiles', 'assets/tilemaps/tiles/tmw_desert_spacing.png'); this.load.tilemapTiledJSON('map', 'assets/tilemaps/maps/desert.json'); } create () { const map = this.make.tilemap({ key: 'map' }); const tiles = map.addTilesetImage('Desert', 'tiles'); this.layer = map.createLayer('Ground', tiles, 0, 0).setVisible(false); this.rt = this.add.renderTexture(400, 300, 800, 600); } update () { this.rt.camera.rotation -= 0.01; this.rt.clear(); this.rt.draw(this.layer); } } const config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config);
class Example extends Phaser.Scene
{
layer;
rt;
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v385');
this.load.image('tiles', 'assets/tilemaps/tiles/tmw_desert_spacing.png');
this.load.tilemapTiledJSON('map', 'assets/tilemaps/maps/desert.json');
}
create ()
{
const map = this.make.tilemap({ key: 'map' });
const tiles = map.addTilesetImage('Desert', 'tiles');
this.layer = map.createLayer('Ground', tiles, 0, 0).setVisible(false);
this.rt = this.add.renderTexture(400, 300, 800, 600);
}
update ()
{
this.rt.camera.rotation -= 0.01;
this.rt.clear();
this.rt.draw(this.layer);
}
}
const config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);