I have several images in an array, and I just don’t quite understand how to swap between the different images in the array, such as by pressing left and right on the keyboard. Like a slideshow, basically. I think I have to change the index number of the array but I don’t really understand what the code would be to do that. I know this is probably extremely simple, but I’m an absolute beginner so any help would be appreciated!
Yeah, sorry, the initial post I sent I realized it had an error in it so I wanted to delete it and redo it, but I didn’t expect you to respond as fast as you did. Apologies for that! Can you tell me how this looks, then?
I looked over it a few times, it looks good, but I am getting an error about the void draw saying "The method image(PImage, float, float) in the type Papplet is not applicable for the arguments (PImage). The function image() expects parameters like: image(PImage, float, float)"
I tried adding some more values to image, image(images[index],0,0);, which actually did allow the program to load, but I now get a "NullPointerException" and the program crashes. I’ve seen this many times before and I never quite understand why it happens.
Thank you again for your patience thus far, by the way! I’m learning a lot from this.
Yeah, even with your changes, running the program just results in a blank grey screen with a red message saying "NullPointerException." The program becomes unresponsive and I have to close it manually, and then it simply says "Could not run the sketch.", nothing about the images … it’s trying to load something that doesn’t exist, I think? But I’m not sure what it would be since the code seems normal from what I’m seeing.
Ah actually I figured it out, for whatever reason changing the format of the images to JPEG made it work! If I could ask one last question, do you know how to make it so that the previous image also disappears when you move to the next one? I’m not sure if that’s just a quick touchup or if it would require another chunk of code. It’s not very important, but just curious.