Multiple collision layers

I’m sort of new with Tiled, managed to get a map of mine running through Phaser by following a tutorial, so far so good.

I’m making a platformer, and would like to have different kind of collision tiles, such as slippery tiles, tiles that fall apart, as well as completely normal collision tiles etc.

I believe to have read that this is a limitation in the tool, inability to have multiple collision layers, but I cannot seem to find that information anywhere now, hence I’m asking here for clarification.

Below is the relevant part of my source code, which I have tried tweaking in various ways with no success:

if (layer.properties.collision) { //collision layer
    collision_tiles = [];
    layer.data.forEach(function (data_row) { //find tiles used in the layer
        data_row.forEach(function (tile) {
            //check if valid tile index and not already in list
            if (tile.index >= 0 && collision_tiles.indexOf(tile.index) === -1) {
                collision_tiles.push(tile.index);
            }
        }, this);
    }, this);
    this.map.setCollision(collision_tiles, true, layer.name);
}

Thanks in advance!

Without knowing anything about Phaser: Generally if you add multiple layers you also need to iterate over multiple layers. Your code only handles a single layer. Looking at the Phaser documentation it looks like you can access all layers via map.layers.

Thanks for replying to my unclear question. I have since realized that the problem is rather Phaser-related than Tiled-related.

Anyway, to further explain, I do take more layers into account, putting them into an array, but somehow it only accepts one collision layer, even if I create more than one layer with “collision true” property. This is what my complete layer-reader looks like in Phaser.

this.layers = {};
	this.map.layers.forEach(function (layer) {
		this.layers[layer.name] = this.map.createLayer(layer.name);
		if (layer.properties.collision) { //collision layer
			collision_tiles = [];
			layer.data.forEach(function (data_row) { //find tiles used in the layer
				data_row.forEach(function (tile) {
					//check if valid tile index and not already in list
					if (tile.index >= 0 && collision_tiles.indexOf(tile.index) === -1) {
						collision_tiles.push(tile.index);
					}
				}, this);
			}, this);
			this.map.setCollision(collision_tiles, true, layer.name);
		}
	}, this);

Sorry, no idea… This is too Phaser specific for me I fear. You might have more luck asking around in the Phaser community.