Why does this code add the object, but not remove it?Note: this prints out true in the window, and if you remove the ' "i".equals(Greenfoot.getKey()) ' from the else if and make it just pressed, it prints out "true removed".
if("i".equals(Greenfoot.getKey()) && !pressed) { getWorld().addObject(instr,350,250); pressed = true; System.out.println(Boolean.toString(pressed)); } else if("i".equals(Greenfoot.getKey()) && pressed) { getWorld().removeObject((Instruct)getWorld().getObjects(Instruct.class).get(0)); System.out.println("Removed"); pressed = false; }