hi, I have some code here but I don't know why it isn't working. I thought it might be because I have the variable "target" for the Greenfoot meathod "isKeyDown" but there wasn't a syntax error. So i'm pretty clueless. help would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class Penguin extends Actor { public String input; private static final String letters = "abcdefghijklmnopqrstuvwxyz" ; public String target = "" + ( char )letters.charAt(Greenfoot.getRandomNumber( 26 )); public void act() { userLetter(); getWorld().showText(input, 356 , 62 ); getWorld().showText(target, 306 , 62 ); } public void signLetter() { String target = "" + ( char )letters.charAt(Greenfoot.getRandomNumber( 26 )); } public void userLetter() { if (Greenfoot.isKeyDown(target)) { signLetter(); } } } |