Jump to content

Distance to tile/floor


fbrcc
 Share

Recommended Posts

Hello Phaser forum. I've been searching this in the forum but I couldn't find an answer.

 

I'm making a platform game and I'd like the player to have a small bounce. The problem is, the small bounce of course sets body.onFloor() to false until the sprites settles in the ground, which can be annoying as the player can't jump until then and idea is to make a fast paced game. I'd like a way to calculate the Y distance from the sprite to the "nearest" floor tile so the player can jump whether he is onFloor() or "really close to the floor" after he touched the ground.

 

I hope this makes sense. Thanks in advance.

Link to comment
Share on other sites

Personally I wouldn't bother checking distance to the floor - I would just capture the time and velocity of the moment the player hits the floor. If the velocity is low enough (i.e. you know it's going to be a normal bounce and not a really high one) then you could let him jump again if he does so within X ms of the time he last hit the ground. I.e. once the bounce starts maybe allow a 250ms window in which he can jump again. Then you don't need to worry at all about how far away he is from something.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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