We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, everyone. I'm onto the second part of my project where I need to cycle through the images in my array one by one with each mouse click.
Here are the relevant instructions:
mouseClicked will do the following (feel free to change details to suit your preference, provided your solution works):
Create a new image, called newimg. Use createImage for that
Call loadPixels on the new image and the original image. This prepares the .pixels array for use.
Here is what I have so far:
PImage [] retinalImages = new PImage[10];
void setup() {
size(800, 800);
for (int i = 0; i < retinalImages.length; i++) {
retinalImages[i] = loadImage("retinal" + i + ".png");
}
}
void draw() {
background(255);
image(retinalImages[0], 0, 0);
}
void mouseClicked() {
if(LEFT == mouseButton) {
PImage retinalImages = createImage(800, 800, RGB);
retinalImages.loadPixels();
}
updatePixels();
}
I tried creating another for loop in the mouseClicked() function, but that didn't work. I think I need to somehow tell the mouseClicked() function where to pull this new image from (my array), but I'm not sure how to do that. If someone could help point me in the right direction I would really appreciate it. Thank you.
Answers
As you see in your setup, you are loading the images:
for (int i = 0; i < retinalImages.length; i++)
but in draw you are showing only one image:
image(retinalImages[0], 0, 0);
Do you know what to do nowÉ
Kf
Instead of always showing image #0, maybe you could have a variable that remembers which image you are currently showing...
Thank you all so much! I was able to get it working. If you can't tell I'm really new to this. Not only that, but my professor has a difficult time explaining things at a beginner level, so I'm mostly teaching myself. I really appreciate all your help.