Skip to content

Tilemaps

samme edited this page Aug 4, 2023 · 32 revisions

Tileset images

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().)

Object layers

Check your object properties

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));

Collision shapes

Clone this wiki locally