Jump to content

Replace the tile below the player


uri
 Share

Recommended Posts

Hi, 

I want to replace the tiles below the player as the he moves 

here is my try: 

var x = player_pos.x + this.player.getWidth()/2;var y = player_pos.y + this.player.getHeight()/2 +10;var tile = this.map.getTileWorldXY(x, y, 16, 16, this.blockedLayer);if (tile != null){  this.map.replace(2, 1, tile.x, tile.y, tile.width, tile.height, this.blockedLayer);}

this replaces some tiles, but not the expected ones

 

I'm not sure how to get the exact tile below the player and if the parameters of replace are correct

 

Do you have any hints for me?

Link to comment
Share on other sites

Ok, I've solved it, with x and y I use removeTileWorldXY and putTileWorldXY

this.map.removeTileWorldXY(x, y, tile.width, tile.height, this.blockedLayer);this.map.putTileWorldXY(1, x, y, tile.width, tile.height, this.blockedLayer);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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