Implement Jumping

Hello,

im making a platform game with the integration of box2D, the lateral movements of my main character are working good with linear velocities.

but i got a problem on jumping method. since i need to disable jumping while its on the air, and re-enable jumping when he touches ground again, or any platform where he stands again. this is to prevent jumping again while on the air.

my first alpha solution was to re-enable jumping when linear velocity on y axis = 0, but as you imagine when he reaches maximum height Vel_y = 0 and it can jump again.

another solution was to enable jumping on the second time that vel_y reaches 0, to prevent air jumping.
but maybe i will have trouble on specific moments when floor inclination is not 0º.

any ideas how to solve this with a better method?
thanks
The best solution i've found so far is colission detection.

when colliding => can jump
when not colliding => cannot jump.

im now solving some details like jumping while touching a wall, the result is like a 5x jump up to the sky.
This is more or less what I use in my "add" and "persist" functions in the contact listener (it's actually slightly more advanced because I'm checking for a lot more variables such as player abilities)

Code:
var actor1:Actor = point.shape1.GetBody().GetUserData() as Actor;
var actor2:Actor = point.shape2.GetBody().GetUserData() as Actor;

if ( point.normal.x <= 0.72 && point.normal.x >= -0.72 && point.normal.y >= -1 && point.normal.y <= -0.69 ){
               
   ( actor2 as Player ).jumpState == 1;

} //end if


In the "remove" function I set the jumpState to 0. When jumpState == 1 the player can jump.
the point.normal is the angle between the player and the tile he is touching. The values I use allow him to jump on flat surfaces and diagonal floors up to slightly more than 45 degrees.
@vedder .. Thank you... Its really working fine...Is there any other solution for that???

Original thread: https://box2d.org/forum/viewtopic.php?t=3319