Thanks for looking at it! I followed your input, but am still having trouble - an error on the name.display() line - ‘cannot invoke display() on array type’. What am I missing?
PImage [] fruit = new PImage[3];
int index = 0;
Names[] name = new Names[fruit.length];
void setup(){
size(300,300);
fruit[0] = loadImage("apple.jpg");
fruit[1] = loadImage("orange.jpg");
fruit[2] = loadImage("pear.jpg");
for(int i = 0; i < fruit.length; i++){
name[i] = new Names(fruit[i]);
}
}
void draw(){
}
void mousePressed(){
background(0);
index = int(random(0,fruit.length));
name.display();
println(index);
}
class Names{
PImage img;
Names(PImage tempImg){
img = tempImg;
}
void display(){
stroke(0);
imageMode(CENTER);
img = name[index];
img.resize(200,200);
image(img,width/2,height/2);
}
}