Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How can I fly with setLinearVelocity? — Gideros Forum

How can I fly with setLinearVelocity?

albert988albert988 Member
edited February 2014 in General questions
Now my game can only fly exactly high because I used setLinearVelocity(0,-10) once player tap.

Check it out
https://itunes.apple.com/us/app/plat-boy/id658060959?mt=8

But I want the hero in my game can fly higher when I press longer and fly not so high when I quickly tap.

Sorry for my English. Anyone can help me? Thanks.

Comments

  • If you are after something more similar to a flappy bird effect, you can achieve it by something like this:
    function jump()
        local x, y = body:getPosition()
        body:applyLinearImpulse(0, -10, x, y)
    end
     
    local timer = Timer.new(200)
    timer:addEventListener(Event.TIMER, jump)
     
    stage:addEventListener(Event.MOUSE_DOWN, function()
        jump()
        timer:start()
    end)
     
    stage:addEventListener(Event.MOUSE_UP, function()
        timer:stop()
    end)
  • No, I don't want the flappy bird effect. The effect is more like Mario style jump.
  • Well either it is flying or jumping all depends on tweaking the velocities and gravity.
    The approach is the same.

    ;)

    zip
    zip
    Box2D_basic.zip
    37K
Sign In or Register to comment.