I'm trying to get my game to switch to an instructions screen when I press a key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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" ); } } |