Jump to content

Layers other than the first of a TileMap have no collision


Pip3r4o
 Share

Recommended Posts

Greetings, I've had the following issue for a couple of days and have no idea how to go about resolving it - I have a TILED JSON with information about the level layout, including 2 arrays of indexes in the layers property. Everything works fine when loading the first layer with its respective name, the same could not be said when loading any other layer from the JSON.

I preload the tilemap

this.load.tilemap('levels', 'levels.json', null, Phaser.Tilemap.TILED_JSON);

Then I proceed to add all assets, then I generate the layer with name: "level1"

var levelMap = game.add.tilemap(key);levelMap.addTilesetImage('wall');levelMap.addTilesetImage('crate');levelMap.addTilesetImage('spikes');levelMap.addTilesetImage('coin');levelMap.addTilesetImage('key');levelMap.addTilesetImage('door');levelMap.setCollisionBetween(1, 3);levelLayer = levelMap.createLayer('level1');

All works good, until I provide another name, a valid one mind you, that doesn't correspond to the the first item of the layers array, that is when the character, who has physics and collision set just falls through everything.

Your help and insight is greatly appreciated. Thank you!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...