przemoo83 Posted July 1, 2015 Share Posted July 1, 2015 HiI'm creating some simple json tilemaps in Tiled and in order to decide which tiles player should collide with I just open a json file and look at the matrix to identify proper numbers. I'm sure there's a better approach because if my map was really huge it would be impossible to identify tiles in this way. How should I do it properly ? Link to comment Share on other sites More sharing options...
shakeshake Posted July 1, 2015 Share Posted July 1, 2015 You could create two layers in tiled, a backgroundLayer and a collisionLayer and then set the collision on the whole layer:this.map.setCollisionBetween(1, 2000, true, 'collisionLayer');You can check the docs for more infos on the params of setCollisionBetween theoutlander and przemoo83 2 Link to comment Share on other sites More sharing options...
InsaneHero Posted July 2, 2015 Share Posted July 2, 2015 What shakeshake said... I would add that doing it this way gives you much greater freedom than using the tile values in the display map. For instance if you want to make a hidden door in a wall, instead of making an exact copy of the wall tiles and tagging them so they don't collide, you can use the same tiles in the display map and just tag that part of the collision map as no collide.If you do anything with a forced perspective angle, having a separate collision map is nearly essential to get good collisions against the multiple layers of the display map. However, if you really really don't want a separate collision layer, the easiest way to do this is to group your tiles so that all the ones that collide are at the end of the tile list, and all the ones which don't collide (including the empty tile) are at the beginning. Then you only need one number - the point where it switches... and you can pad the no-collided tiles so that number is always 128 or something easy to remember like that. For collisions you just say:if (collidedTileNumber >= firstCollisionTileNumber)// we collidedelse// we didn't collide przemoo83 and drhayes 2 Link to comment Share on other sites More sharing options...
przemoo83 Posted July 2, 2015 Author Share Posted July 2, 2015 Great tips guys. Thanks a lot. Link to comment Share on other sites More sharing options...
Recommended Posts