Make An Object Jump Only Once

I am making an app that is a simple game with a ball. I have it set up that when you touch anywhere on the screen the ball bounces. The only problem that I have is that you can double bounce and keep pressing the button and the object will always stay in the air. Here is my code for jumping...

physics.addBody( circle, "dynamic",{ density=1, friction=0.5, bounce=0.3 })
local onTouch = function(event)
timer.performWithDelay(1000, event )
circle:applyLinearImpulse(5,-3, circle.x, circle.y)
end
Runtime:addEventListener("touch", onTouch)

its fairly easy, i use a function like that:

1
2
3
4
5
6
7
8
9
local function jump(event)
print(person.y)
        if event.phase == "ended" then
        if person.y > person.y0 - 20 then
        person:applyForce(0,-50, person.x, person.y)
        end
        end
return true
end
views:1282 update:2011/12/29 9:44:01
corona forums © 2003-2011