Kobaltic Posted February 9, 2014 Share Posted February 9, 2014 I can't get map collision to work for some reason. I assume the collide information is for the frame id and not the location on the map. Either way neither works. Here is my stuffvar layer;var player;function create(){ map = game.add.tilemap('town'); map.addTilesetImage('walls', 'walls'); map.addTilesetImage('broken', 'broken'); map.addTilesetImage('towers', 'towers'); map.addTilesetImage('house', 'house'); map.addTilesetImage('grass', 'grass'); map.setCollision(29); //This is frame id 29 grassLayer = map.createLayer('grass'); layer = map.createLayer('walls');}function update() { game.physics.collide(player, layer);} Link to comment Share on other sites More sharing options...
rich Posted February 9, 2014 Share Posted February 9, 2014 Turn on layer.debug = true (make sure game is in canvas mode) and look at the result. All tiles set to collide will be outlined. Also you don't need to put the tileset names twice if they're the same ('walls', 'walls') can just be ('walls) Link to comment Share on other sites More sharing options...
Kobaltic Posted February 10, 2014 Author Share Posted February 10, 2014 After many hours of agony I found that the layer in the JSON file has to be the first one listed for the collision to work. It doesn't seem to matter for anything else about the layer as long as it is listed first. Although this also tells me that we don't have multi-layer collision. Link to comment Share on other sites More sharing options...
jcs Posted February 10, 2014 Share Posted February 10, 2014 Tilemap.setCollision() takes a parameter that specifies which layer you're setting it on (see Tilemap.js line 432) Link to comment Share on other sites More sharing options...
Kobaltic Posted February 11, 2014 Author Share Posted February 11, 2014 Thanks so much dunno how I missed that one. Link to comment Share on other sites More sharing options...
RestingCoder Posted February 11, 2014 Share Posted February 11, 2014 You may also want to change which post is marked as the answer for this thread. Link to comment Share on other sites More sharing options...
Recommended Posts