We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi ! So, I know you need to set up a server if you want loadimage() to work properly, so I did, then, write my code : everything works, perfect.
But the problem now, is that when I try to upload my mini game on a website, the images won't load... I'm using 000webhost to host my website.
Basically, my code works on a local server but not when it's uploaded on a web server :-/
var bg;
bg= loadImage("./src/images/bg");
If someone had the same problem and know how to fix it, it would be great if you help me ! Thank you :)
Answers
What shows up in the developer tools? Do you see any errors? What URL is it trying to load those images from?
Also why do you have a period in the path you're passing into the
loadImage()
function?The error in the console: Failed to load resource: the server responded with a status of 404 ()
The url of the the image it is trying to reach : https://mywebsite.000webhostapp.com/src/images/bg
And i changed the path to remove the periods, now i use :
loadimage("src/images/bg");
I tried again and it did not work, but now the error is a bit different :
GET https://mywebsite.000webhostapp.com/src/images/bg 404 ()
Where is your file extension? Is the name of your file literally
bg
without anything after it? I would think it should bebg.png
orbg.jpg
or something.Thank you very much sir ! I add the extentions and it worked !