This site requires JavaScript, please enable it in your browser!
Greenfoot back
biferony
biferony wrote ...

2015/3/14

Greenfoot Background error

biferony biferony

2015/3/14

#
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.
       World Question1 = getWorld();
       GreenfootImage bg1 = new GreenfootImage("Question1.png");
       GreenfootImage bg2 = new GreenfootImage("Question2.png");
       if (QuestionNumber == 2)
        {
            Question1.setBackground(bg2);
        }
Do any of you guys know how to fix this? Thanks.
danpost danpost

2015/3/14

#
Double-check the spelling (including capitalization) on your file names (including suffixes). The properties of the file should show the exact suffix.
biferony biferony

2015/3/15

#
danpost wrote...
Double-check the spelling (including capitalization) on your file names (including suffixes). The properties of the file should show the exact suffix.
Thanks! I had the first letters capitalized in the code, but not in the files so I didn't notice.
You need to login to post a reply.