Hi
I'm making a game using Greenfoot as a school project, and have run into a problem with the isKeyDown()-method.
The game has an intro in which images are shown, and then the player should press "enter" to continue. This is accomplished with:
The problem is that if you press enter a bunch of times, the next time waitForEnter() is called, it breaks out of the loop immediately. Even though isKeyDown() is supposed to return true only if the key is CURRENTLY pressed down, it seems to remember previous presses.
It even remembers key-presses when changing worlds using setWorld(), as after the intro a new World starts where pressing enter has a certain effect, and if you press enter during the end of the intro, Greenfoot registers that enter is pressed down as soon as the new world starts.
Is this a known issue or am I doing something wrong?
public void waitForEnter() { Greenfoot.delay(1); //need this to allow things on the stack to execute before entering the loop while (true) { if (Greenfoot.isKeyDown("enter")) { break; } } }