P5.js - sketch trying to load images from previous sketches

I’m trying to call an array of images. My sketch keeps trying to load images which are not added within the sketch. These files were loaded in previous sketches, therefore this somehow overrides the images I am attempted to load. The images in the previous sketch were named ‘0.png’ ‘1.png’ etc etc. I have now named my images ‘A.png’, ‘B.png’ etc

Here is my code:

function preload() {
for (var index = 0; index < totalImages; index++) {
allImages[index] = loadImage(index + “.png”);
}

my error:

It looks like there was a problem loading your image. Try checking if the file path [https://editor.p5js.org/bekah_mbrown/sketches/osyQni0v1/7.png] is correct, hosting the image online, or running a local server.[https://github.com/processing/p5.js/wiki/Local-server]

If you named your images ‘A.png’, ‘B.png’, etcetera, then using index (which is a number) to form the file’s name won’t work.

Or did I misunderstand you?

but could use

  for ( let i = 0; i < 5 ; i++ ) print( char(i+65) +'.png');

prints

A.png 
B.png 
C.png 
D.png 
E.png 
1 Like