I used the following tutorial to construct my jump:
https://docs.coronalabs.com/tutorial/games/allowJumps/index.html
And I am having an issue.
When I set the sensorOverlaps to 0 and tap on the screen to jump it does not jump.
When I set the sensorOverlaps to 1 and tap on the screen it jumps, but I can jump infinite times.
I only want my character to be able to jump one time.
Please advise on this problem, thank you.
Also, here is the code:
anim.sensorOverlaps = 0 local function jump(event) if ( event.phase == "began" and anim.sensorOverlaps \> 0 ) then local vx, vy = anim:getLinearVelocity() anim:setLinearVelocity( vx, 0 ) anim:applyLinearImpulse( nil, -225, anim.x, anim.y ) anim:setSequence("jump") anim:play() end end local function sensorCollide(event) if ( event.element1 == 2 and event.object2.objType == "ground" ) then if ( event.phase == "began" ) then anim.sensorOverlaps = anim.sensorOverlaps + 1 elseif ( event.phase == "ended" ) then anim.sensorOverlaps = anim.sensorOverlaps - 1 end end end Runtime:addEventListener("touch", jump) Runtime:addEventListener("collision", sensorCollide)