panegalli Posted May 22, 2015 Share Posted May 22, 2015 Hello guys, i have a problem.I can't destroy one type of tile index. I make my tiles in the tile editor and export for json. My tile index are:1 = grass -> destructible.2 = ground -> destructible.3 = rock -> not destructible. (function create)//carregamento de mapa//adiciona mapamap = game.add.tilemap('mapa');map.addTilesetImage('tiles');layer = map.createLayer('cenario'); //maps tile: 1 = grass : 2 = ground : 3 = stone//map.setCollisionBetween(1, 3, true, 'cenario'); // index of the tile //layer.debug = true;layer.resizeWorld(); function update(){game.physics.arcade.collide(player, layer, function(player, layer){//console.log('Colisão com bloco = ', layer.index);//console.log(player.body.blocked);if (tecla.down.isDown) {if(player.body.blocked.down){destroyBlock(layer.index);}};}, null, this); var indextileblock;function destroyBlock(indextileblock){switch (indextileblock){ case 1: //grass indextileblock.destroy(); break; case 2: //ground indextileblock.destroy(); break; case 3: //stone break;} Thanks Link to comment Share on other sites More sharing options...
Recommended Posts