Flappy Bird Bounce effect, on double touch

Hi guys, i’m developing a game where the character bounces much like the flappy bird character. I have it working well, but i’m handing the bouncing effect with a touch event and when the user double touches really quick it basically doubles the force behind the player. 

Also, take for example if the player is dropping from a higher height then the gravity seems to be too much and i have to touch many more times to bring the player back up, and i just can’t seem to figure out how to make every touch consistent with the amount the character bounces.

here is my function for the bounce effect:

[lua]

function flyUp(event)

  if event.phase == “began” then

       

    if gameStarted == false then

      player.bodyType = “dynamic”

      instructions.alpha = 0

      tb.alpha = 1

      addColumnTimer = timer.performWithDelay(1000, addColumns, -1)

      moveColumnTimer = timer.performWithDelay(2, moveColumns, -1)

      gameStarted = true

      player:applyForce(0, -300, player.x, player.y)

                         

     else 

       

     player:applyForce(0, -460, player.x, player.y)

    end

  end

end

[/lua]

…and here is where my player is defined as a physics body:

[lua]

physics.addBody(player, “static”, {density=.106, bounce=.1, friction=1, radius = 30})

[/lua]

any help would be extremely appreciated, i just want the player to always move up the same amount no matter how many taps and how much he has dropped.

Thanks

i find using standart transition.to is better than using applyLinierImpulse or applyForce methode.

 

also i just made a game with this method here

https://play.google.com/store/apps/details?id=com.gmail.sukmaa.gozilla

the flapping tap is better and more predictable, please have a look, and please put a comment and rate :smiley:

 

[lua]–main.lua–

vertices = {-22,-15,20,-20,23,13,-27,26,-18,14}

bird = display.newPolygon( 100, 100, vertices )

function fall( event )

    falling = transition.to( bird, {time=800, y=bird.y+500, transition=easing.inSine} )

    fallrot = transition.to( bird, {time=500,rotation=60, transition=easing.inSine} )

end

function upp( event )

    if event.phase == “began” then

        bird.rotation = -20

        transition.cancel() --cancel all transition

        up = transition.to( bird, {y=bird.y - 50,time=200,transition=easing.outSine, onComplete=fall})

    end    

end

Runtime:addEventListener(“touch”, upp )

[/lua]

i find using standart transition.to is better than using applyLinierImpulse or applyForce methode.

 

also i just made a game with this method here

https://play.google.com/store/apps/details?id=com.gmail.sukmaa.gozilla

the flapping tap is better and more predictable, please have a look, and please put a comment and rate :smiley:

 

[lua]–main.lua–

vertices = {-22,-15,20,-20,23,13,-27,26,-18,14}

bird = display.newPolygon( 100, 100, vertices )

function fall( event )

    falling = transition.to( bird, {time=800, y=bird.y+500, transition=easing.inSine} )

    fallrot = transition.to( bird, {time=500,rotation=60, transition=easing.inSine} )

end

function upp( event )

    if event.phase == “began” then

        bird.rotation = -20

        transition.cancel() --cancel all transition

        up = transition.to( bird, {y=bird.y - 50,time=200,transition=easing.outSine, onComplete=fall})

    end    

end

Runtime:addEventListener(“touch”, upp )

[/lua]