The problem I'm having is that I don't know how to make the character stop jumping.
For example, when I constantly hit space it keeps jumping and jumping. When I press space I want it to jump and while the MC is jumping I want to disable the space button (or if possible could you also tell me how to disable MouseEvents
) so that while in the air the MC can only jump once.
var gravity = 0.8;
var floor = 251;
player.y = floor;
player.speedY = 0;
player.impulsion = 10;
stage.addEventListener(Event.ENTER_FRAME, enterframe);
function enterframe(e:Event) {
player.speedY += gravity;
player.y += player.speedY;
if(player.y > floor) {
player.speedY = 0;
player.y = floor
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, space);
function space(e:KeyboardEvent) {
if(e.keyCode == Keyboard.SPACE) {
player.speedY = -player.impulsion
}
}