Loading images sometimes works and sometimes doesn't


#1

Here’s what I’m trying to do.

Sometimes when you refresh it works just fine.
Sometimes I get this error:
image
If you can’t see its says:
Uncaught TypeError: Cannot read property ‘width’ of undefined
at e.image (p5.min.js:9)
at draw (sketch.js:87)
at e.redraw (p5.min.js:8)
at e. (p5.min.js:7)

There’s a link to the Github page with all the code in it in the website. All of the code is in the sketch.js file.

Is there something I’m doing wrong? Or is this a p5.js bug? I also wish to know what’s wrong in this situation.


#2

You’d make things much easier for you if you’d just stick to preload() to load ALL of your assets! :roll_eyes:


#3

I want to show the loading icon so that’s why I put them in setup. I put the loading icon in preload.


#4