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

2021/3/11

Image doesn't work

liekevaniep01 liekevaniep01

2021/3/11

#
Hello, I have a problem. When I play the game it shows an error, but I don't know why. This is the code: private void updateText() { GreenfootImage newImage = new GreenfootImage ("alienschip.png"); newImage.setColor (new Color(205,51,51)); newImage.setFont (new Font ("Comic Sans MS", 20)); newImage.drawString(punten + "", 40, 20); setImage (newImage); } It gives the error: java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: alienschip.png I know for sure that the files name is correct.
danpost danpost

2021/3/11

#
Make sure the file is in the images folder within your scenario folder. Then make sure the name given in code exactly matches the file's name (including case -- for name and suffix).
liekevaniep01 liekevaniep01

2021/3/11

#
I have exported the file again in png and it works now!
You need to login to post a reply.