I'm trying to get my game to switch to an instructions screen when I press a key.
public class Castle extends World { /** * Constructor for objects of class Castle. * */ public Castle() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(800, 500, 1); setBackground("Castle-stock3197.jpg"); goToInstructions(); } public void goToInstructions() { if(Greenfoot.isKeyDown("space")) { Greenfoot.setWorld(new Instructions()); } } } to this... public class Instructions extends World { /** * Constructor for objects of class Instructions. * */ public Instructions() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(800, 500, 1); setBackground("Castle.jpg"); } }