Hi,
sorry but I have another question:
I want Greenfoot to do nothing until a Key is pressed. How can i realise it?
Thx for help:)


1 2 3 4 | Key k1 = "space" ; while (getKey() != k1){ } |
1 2 3 4 5 6 7 | //in your act method if (theBooleanForTheWorldChangingCondition) { if (Greenfoot.isKeyDown( "space" )) { theBooleanForTheWorldChangingCondition = false ; //you should use a shorter name I think; setWorld(theOtherWorld); //the command you used before to change the world; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // add this boolean to the class boolean waitingForSpaceKey = false ; // to be used as a flag // in the 'if' block that determines intersection waitingForSpaceKey = true ; // sets flag // in the 'act' method if (waitingForSpaceKey) // catches flag { if (Greenfoot.isKeyDown( "space" )) // check for 'space' { waitingForSpaceKey = false ; // clears flag Greenfoot.setWorld( new WorldName()); // changes world } return ; // just waiting for keypress } |
1 | if (WorldName.actorsHalted) return ; |
1 2 3 | if (isKeyDown( "n" ){ } |
1 2 3 | if (isKeyDown( "space" ){ } |