Jump Button how to prevent multiple jumps

I'm making a game where the actor need to jump, I have created a jump button. When i press jump everything works great my problem is that I want that the actor only jump when it is on the floor and the jump button is pressed.

For example:
the actor is in the floor I press the button and he jump, if I keep the jump pressed I don't want more jumps, it's one tap one jump. (Till here I can make)
The problem is if I press jump and when the actor is in the air and I press jump again and keep it down, when the actor touch the floor he jumps again, I want to prevent this.

Someone know how to solve this?

Comments

  • tarsiustudiotarsiustudio Member Posts: 130
    hello, you have to do is create a false Boolean attribute called eg jump game. then add a rule that when you touch the button jump change attribute to true. the hero do that if it is true then jump jump. and finally add a rule that if the hero touches the ground change attribute to false. I hope it's what you say because I do not understand English very well.I let the direction of a template I hope you serve https://www.dropbox.com/s/lxafuy7isjn98xd/jump.zip
  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    edited December 2013
    Create a boolean attribute called Jump
    Button: when touch is pressed change game.jump to true

    Character: when jump is true, and overlaps/collides with ground change self.motion.linearvelocity.y to 250
    Otherwise change attribute self.motion.linearvelocity.y to 0

    Template attached below

    Edit: tarsiustudio beat me to it :p
  • kandalfkandalf Member Posts: 7
    edited December 2013
    Thank you tarsiustudio, your example was exactly what I want. I can swear that this was my first attempt, now I'm feeling really stupid.

    Thank you bjandthekatz, but your in your code if you keep the button pressed the actor continues to bounce.

    EDIT: I FOUND A PROBLEM

    tarsiustudio in you code imagine that you are over a block that since you are touching the floor the jumping flag is false, if you move left or right and fall you can jump in the air.
  • tarsiustudiotarsiustudio Member Posts: 130
    @Kandalf I'm glad it was what I wanted.

    Edit: @bjandthekatz I can put your projects as you put it? Do not know and I had to upload it to dropbox jejej
  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    @tarsiustudio I believe its only for pro members.
Sign In or Register to comment.