Sawyer Posted October 6, 2015 Share Posted October 6, 2015 I've created a basic map using Tiled and imported it into my Phaser game. That I can do without any trouble. What I can't get quite get is how collision works. I've loaded in the assets; game.load.tilemap('level1', 'assets/tilemap.json', null, Phaser.Tilemap.TILED_JSON);game.load.image('tiles', 'assets/tileset.png'); And added them to the game and got my ground layer: map = game.add.tilemap('level1');map.addTilesetImage('tileset', 'tiles');ground = map.createLayer('ground'); I'm not sure where to go from here in regards to collision detection. I've seen in tutorials about using setCollisionBetween( ) but I'm not sure what to pass in to this. My map's json for ground is just 0 and 3. I've tried map.setCollisionBetween(3, 3); and map.setCollisionBetween(1, 3); each with on luck. My players physics are turned on and I've set it to detect collisions in the update( ). Not sure where to go from here. Any help is appreciated. Link to comment Share on other sites More sharing options...
jmp909 Posted October 8, 2015 Share Posted October 8, 2015 please try post Phaser 2 questions in the main Phaser forum http://www.html5gamedevs.com/forum/14-phaser/(this is Phaser 3) anyway you can pass in those 2 tile indexes as an array setCollision(indexes, collides, layer, recalculate)Sets collision the given tile or tiles. You can pass in either a single numeric index or an array of indexes: [ 2, 3, 15, 20]. The collides parameter controls if collision will be enabled (true) or disabled (false).http://phaser.io/docs/PIXI.Spine.html/Phaser.Tilemap.html#setCollision in your case thereforemap.setCollision([0,3], true, 'ground')although you can leave off the last 2 arguments as 'collides' param is true by default and you only have one layer J Sawyer 1 Link to comment Share on other sites More sharing options...
Sawyer Posted October 13, 2015 Author Share Posted October 13, 2015 Thanks jmp909, I've got it working now. sorry I didn't notice the forum sections for the different versions of Phaser. Link to comment Share on other sites More sharing options...
Recommended Posts