Jump to content

Player body collision example


Recommended Posts


I haven't been able to find or seen in the documentation a player.body.collision example, I want to make it so when, the player.body collides with tile 55, I then run a tile replace function something like this;

hero.body.collide(55, 'buttonSwap');

function buttonSwap(){
     map.replace(55, 56);

This was the code I picked up when searching for this action but I think my understanding is that the map.replace changes all the tiles that have an id of 55 to 56 not the one you stand on which I will need to look at further.
Has anyone used or seen anything similar, if there is something in the documentation where should I be looking.

I found this might be the solution to the second half but I'm not sure how to run it when the body collides with the tile. 

function buttonSwap(){
map.currentLayer.replaceTile(80, 81);
Link to comment
Share on other sites


  • Recently Browsing   0 members

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