aberrantmind Posted January 26, 2014 Share Posted January 26, 2014 I've been stuck on this problem for a few days now. I'm trying to set collisions by layer and cannot figure it out. I can set collisions between sprites and groups, but I can't get tiles to work. here's the relevant code: in load: game.load.tilemap('overworld', 'assets/testSuite.json', null, Phaser.Tilemap.TILED_JSON); game.load.tileset('tiles', 'assets/overworld.png',16,16); in create:map = game.add.tilemap('overworld'); tileset = game.add.tileset('tiles');tileset.setCollision(26, true, true, true, true);// the above doesn't seem to do anything//I want to add collision with the player against a specific tile index against a specific layer://26 are the tree tiles which are on layer2//97 is the ocean tile which are on layer0 layer0 = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0);layer0.resizeWorld(); layer1 = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 1);layer2 = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 2);layer3 = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 3); From what I understand tilemapLayer is just for rendering, tile and tilesets are for setting collisions. Link to comment Share on other sites More sharing options...
jpdev Posted January 27, 2014 Share Posted January 27, 2014 You have to call Phaser.Physics.Arcade.collide(Sprite, Layer); The setCollision call only sets up the tiles that will be used for collision if (when) collide is called in the update routine. Link to comment Share on other sites More sharing options...
Recommended Posts