okay so I have a jump button and a runtime listener function for when the jump button is pressed.
So whenver the jump button is pressed I apply linear impulse to the game hero.
local function controls(event) if(event.phase=="began") then if (buttonpressed.id=="jump") then hero:applyLinearImpulse(0,-10,hero.x,hero.y) end elseif(event.phase=="ended") then end end
Now problem is if if the user keeps on tapping the jump button then the hero keeps on going up. I cant think of anyhting to counter this. One thing I could do is change the above code to:
local function controls(event) if(event.phase=="began") then if (buttonpressed.id=="jump" and hero.y\>display.contentHeight/2) then hero:applyLinearImpulse(0,-10,hero.x,hero.y) end elseif(event.phase=="ended") then end end
But this would still allow the jumping button to work until half of the screen is reached.
Kindly help me on this.
Thanks