Hey I need help with controlling jump. Ok what I want it when the character jump he can double jump in midair, and not any further than that.
Here is the code below
[code]display.setStatusBar( display.HiddenStatusBar )
local physics = require “physics”
physics.start()
local background = display.newImage( “background.jpg” )
local ground = display.newImage( “ground.png” )
ground:setReferencePoint( display.BottomLeftReferencePoint )
ground.x, ground.y = 0, 320
local groundShape = { -240,-20, 240,-20, 240,20, -240,20 }
physics.addBody( ground, “static”, { friction=1.0, density=1.0, bounce=0, shape=groundShape } )
local character = display.newImage( “character.png” )
character.x = 70
character.y = 230
physics.addBody( character, { friction=1.0, density=1.0, bounce=0.3, radius=35 } )
character.isFixedRotation = true
local function onScreenTouch( event )
if event.phase == “began” then
– make character jump forward
character:applyForce( 400, -2100, character.x, character.y )
end
return true
end
Runtime:addEventListener( “touch”, onScreenTouch ) [/code]
The problem with the above code is he jumps in midair and basically you click on the background as many time and it would not stop going up. I just want my character to double jump for the code above.
Help is appreciated
[import]uid: 17058 topic_id: 21397 reply_id: 321397[/import]