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

2024/2/8

Getting Exception instantiating world class:java.lang.IllegalArgumentException

jlau jlau

2024/2/8

#
Hi, I am getting Exception instantiating world class:java.lang.IllegalArgumentException - null on my scenario https://www.greenfoot.org/scenarios/32849 Please help as I am not sure why
nccb nccb

2024/2/8

#
The Javascript exceptions in the console can give a hint. One problem seems to be that your scenario autoplays music, and the browser refuses this unless the user has already interacted with the page. But even if you do interact straight away, it seems that it fails due to the line:
setImage("/world/flat-tile.png");
in Platform's constructor. I suspect the problem may relate to the leading slash, as it then tries to load the image from https://www.greenfoot.org/world/flat-tile.png which isn't going to work. I think if you remove the leading slash (to make it a relative rather than absolute path) it may resolve the issue, but I'm not 100% sure if images in subdirectories works correctly with Greenfoot's bundling and the online image resolution. Maybe someone else who has tried it in their scenario can share their experience.
danpost danpost

2024/2/8

#
jlau wrote...
Hi, I am getting Exception instantiating world class:java.lang.IllegalArgumentException - null on my scenario << Link Omitted >> Please help as I am not sure why
I believe the problem is that you left all the System.out.println(...) statements in your code when you uploaded it. Try removing them first (or comment those lines out of the code).
You need to login to post a reply.