'Invalid Tilemap Layer ID
I was doing my game in phaser 3 when I went to add a tilemap created in tiled, I followed several tutorials, I did and redid the code several times and even then it always gives me the same invalid ID error.
unsuccessful attempts:
- Tried to manually make the tilemap;
- Tried using JSON files;
- I tried to use a single layer;
- I tried to use the names according to the tiled layers;
- I tried using different names;
here follows the code:
import './phaser'
const config = {
type: Phaser.AUTO,
parent: "phaser-example",
width: 1824,
height: 960,
physics: {
default: 'arcade'
},
scene: {
preload: preload,
create: create
}
};
export const game = new Phaser.Game(config)
function preload()
{
this.load.image('terrain', './complementos/tilemaps/terrainBasic.png')
this.load.tilemapTiledJSON('map', './complementos/tilemaps/basicLand.json')
}
function create()
{
const teste = [[0,1,2],[0,1,2],[0,1,2]]
const map = this.make.tilemap(teste)
map.addTilesetImage('terrainBasic','terrain', 32, 32)
const layer = map.createLayer(0,'land', 0, 0)
}
I don't know if it changes much but I was using react together with phaser 3, but my react code only had styling.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
