Jump Button how to prevent multiple jumps
kandalf
Member Posts: 7
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?
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
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
Need Help? Email Me | Templates | Full Game Source Code
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.
Edit: @bjandthekatz I can put your projects as you put it? Do not know and I had to upload it to dropbox jejej
Need Help? Email Me | Templates | Full Game Source Code