KeyboardFire Posted August 24, 2014 Share Posted August 24, 2014 Here's my current code: function create(level) {¬ phaser.physics.startSystem(Phaser.Physics.NINJA); game.map = phaser.add.tilemap('tilemaps_' + level); game.map.addTilesetImage('images_tiles_' + level); game.layer = game.map.createLayer('tilemaps_' + level + '_layer'); game.layer.resizeWorld(); if (level == 'fire') { game.map.setCollision(1); // the array at the end isn't actually optional; bug in Phaser methinks game.collideLayer = phaser.physics.ninja.convertTilemap(game.map, game.layer, [1, 1, 1, 1, 1, 1, 1, 1]); } ...} function update(level) { ... if (level == 'fire') phaser.physics.ninja.collide(game.player, game.collideLayer); ...} It just won't work. The player flies right through the ground tiles that he's supposed to walk on. I've tried every possible combination of game.layer, game.currentLayer, game.map.layer, etc., but none of them seem to be working. I can see the tileset load correctly, and everything else is working fine. So why won't this work? Link to comment Share on other sites More sharing options...
lewster32 Posted August 24, 2014 Share Posted August 24, 2014 The example seems to suggest you have to check collision using a body method against each tile in the array: for (var i = 0; i < game.collideLayer.length; i++) { game.player.body.collideCircleVsTile(game.collideLayer[i].tile); } Link to comment Share on other sites More sharing options...
KeyboardFire Posted August 24, 2014 Author Share Posted August 24, 2014 Thanks! That worked perfectly. (For the record, I used game.player.body.aabb.collideAABBVsTile(game.tiles.tile); instead, but the idea is the same.) Link to comment Share on other sites More sharing options...
Recommended Posts