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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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