Jump to content

Programming a ladder


pdiddles03
 Share

Recommended Posts

I'm using tiled to set  an object for a ladder,  in phaser,  i am using "createFromObjects" to create the object, i can perform the overlap collision in order to let the user climb, but my problem comes from when the user reaches the top, how do i detect when the user has reached the top, re enable the gravity, and not allow them to fall down?  

Link to comment
Share on other sites

Not sure but i think you can do something like this:

// update function

var currentTile = map.getTile(mapLayer.getTileX(player.body.x), mapLayer.getTileY(player.body.y), mapLayer);

if (currentTile.properties.isLadder && cursors.up.isDown){
   player.body.velocity.y = -200;
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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