im trying to make a double jump method for my game the method works but it registers the button presses to fast and just jumps forever
here is the code i have for movement and for double jump i am looking for a way to slow down how fast it registers a button click
public void doubleJump()
{
if (numJumps == 1)
{
vSpeed = -jumpStrength;
setImage(new GreenfootImage("PlayerDouble.png"));
fall();
}
}public void act()
{
if (Greenfoot.isKeyDown("left"))
{
moveLeft();
Actor p = this.getOneIntersectingObject(Platforms.class);
if(p != null)
{
moveRight();
}
}
if(Greenfoot.isKeyDown("right"))
{
moveRight();
Actor p = this.getOneIntersectingObject(Platforms.class);
if(p != null)
{
moveLeft();
}
}
if (Greenfoot.isKeyDown("up") && onPlatforms() && numJumps < 2)
{
jump();
numJumps++;
}
hitSpike();
hitGoal();
if (onPlatforms())
{
vSpeed = 0;
numJumps = 0;
setImage(new GreenfootImage("Player.png"));
}
else
{
fall();
}
if (Greenfoot.isKeyDown("up") && numJumps < 2 && dbJumped == false)
{
doubleJump();
dbJumped = true;
}
}

