Jump to content

How can I get collision between a sprite and a tilemap in Ninja physics to work?


Recommended Posts

Here's my current code:


function create(level) {¬
    game.map = phaser.add.tilemap('tilemaps_' + level);
    game.map.addTilesetImage('images_tiles_' + level);
    game.layer = game.map.createLayer('tilemaps_' + level + '_layer');
    if (level == 'fire') {
        // 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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...