Reputation: 11
I'm working on a game, and have made a map in Tiled which i was trying to render. I got the following error when trying to create a static layer using createStaticLayer()
:
Invalid Tilemap Layer ID: walls
I checked the name, but it is correct. The json file itself loads properly, and everything the documentation told me to pay attention to is fine, yet the error continues to be thrown.
function preload () {
this.load.setBaseURL('http://127.0.0.1:3000/asset?file=');
this.load.image('sky', 'assets/images/space.png');
//this.load.image('ground', 'assets/images/platform.png')
this.load.image('star', 'assets/images/star.png');
//this.load.image('tile', 'assets/images/tile.png');
this.load.image('tile_set', 'assets/tilesets/tileset_cc_1.png');
this.load.tilemapTiledJSON("map_cc", "assets/maps/test_map_cc.json")
}
function create () {
this.add.image(960, 540, 'sky');
//map, tilesets
let map = this.make.tilemap("map_cc");
let cc = map.addTilesetImage("cc", "tile_set");
//layers
let wall = map.createStaticLayer("walls", [cc], 0, 0);
}
Is there something i'm missing that no question here has had an answer to yet? i'm completely lost and have no idea what i'm doing wrong.
Upvotes: 1
Views: 1106
Reputation: 834
I know this is an old post, but if someone else is having a similar problem:
When making the tilemap, make sure to make it like this:
this.make.tilemap({key: 'map_cc'});
This way, it should load you map correctly
Upvotes: 1