-
Notifications
You must be signed in to change notification settings - Fork 4
Tilemaps
samme edited this page Aug 4, 2023
·
32 revisions
- Modular Game Worlds in Phaser 3 — Static Maps
- Modular Game Worlds in Phaser 3 — Dynamic Platformer
- Modular Game Worlds in Phaser 3 — Procedural Dungeon
Every tilemap layer needs at least one tileset image to render. You assign this with addTilesetImage()
.
load.image()
is fine for this, but you can also use load.spritesheet()
(with the appropriate frame dimensions) if you want to use the the same tileset image as a multiframe texture for other game objects like sprites. (And if you want createFromObjects()
to assign texture frames automatically, you must use load.spritesheet()
.)
const map = this.add.tilemap(/*…*/);
const [firstObjectLayer] = map.objects;
console.info('Object properties in %s:', firstObjectLayer.name);
console.table(firstObjectLayer.objects);
console.info('Object custom properties in %s:', firstObjectLayer.name);
console.table(firstObjectLayer.objects.map(o => o.properties));