In my program, I am trying to make it to change the background every time a place in clicked. Everything works besides the chaining the background. It compiles fine, but when I try to run the game I get this error:
java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: Question1.png
at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:279)
at greenfoot.GreenfootImage.<init>(GreenfootImage.java:108)
at Clicker.act(Clicker.java:38)
at greenfoot.core.Simulation.actActor(Simulation.java:583)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:541)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
Caused by: java.io.FileNotFoundException: Could not find file: Question1.png
at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:537)
at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:276)
... 6 more
This is my code which messed it up.
Do any of you guys know how to fix this? Thanks.
World Question1 = getWorld();
GreenfootImage bg1 = new GreenfootImage("Question1.png");
GreenfootImage bg2 = new GreenfootImage("Question2.png");
if (QuestionNumber == 2)
{
Question1.setBackground(bg2);
}