Hello, I am having a bit of an issue with the isKeyDown command. It obviously detects if a key is being held, however I want to make it stop detecting at a certain point.
Here's my code:
I would like the canHitOrb integer to stay as 0 unless the player hits the space bar in midair, in which case it will change to 1 (by the way, my old account is CreatorMoon and yes, this is for my Greenfoot Geometry Dash recreation). If onBlock and onGround (both of them being booleans) are true, the player is not in midair, and vice versa for when they are false. The issue that I have here is that no matter the conditions, as long as the space bar is being held, canHitOrb is equal 1 (on release it becomes 0). Any help would be appreciated. I'd be happy to provide my full player code if it would help.
public void jump() { if (Greenfoot.isKeyDown("space") && onBlock()) { vSpeed = jumpStrength; fall(); canHitOrb = 0; } else if (Greenfoot.isKeyDown("space") && onGround()) { vSpeed = jumpStrength; fall(); canHitOrb = 0; } else if (Greenfoot.isKeyDown("space") && !onBlock()) { canHitOrb = 1; } else if (Greenfoot.isKeyDown("space") && !onGround()) { canHitOrb = 1; } else { canHitOrb = 0; } }