Jump to content

Moving on edges


Recommended Posts

I'm new at using Phaser and I'm facing an issue that I would appreciate your help if you could guide me on how to solve it.

I want my character to move on the play area if and only if is attached to a surface either that being a side, floor or ceiling of a sprite. I have managed to check if he is attached to these edges but the problem happens when the velocity of the character causes it to move past the end of the edge and stand on a point that is further away from the corner of such an object. To make things a little more clear, imagine a rectangle of 100 pixels wide and 50 pixels tall and the character has to move on all edges of this rectangle without going over the 100th pixel in the x dimension nor the 50th pixel in the y dimension. If the velocity is too high in either direction then when the update method will get called the position of the character will be past the limiting positions.

So the question is, is there a way to check ahead the attaching edge based on the velocity of the character in order to make sure that when the next update function call happens the character will still be attached to the edge?


Link to comment
Share on other sites


  • Recently Browsing   0 members

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