like this with arrays
(tested)
- //
- int indexBigImage = -1;
- //
- PImage big [] = new PImage [7];
- //
- PImage small [] = new PImage [7];
- //
- void setup()
- {
- size(800, 600);
- //
- big[1] = loadImage("0big.jpg");
- big[2] = loadImage("1big.jpg");
- big[3] = loadImage("2big.jpg");
- big[4] = loadImage("3big.jpg");
- big[5] = loadImage("4big.jpg");
- big[6] = loadImage("5big.jpg");
- //
- small[1] = loadImage("0small.jpg");
- small[2] = loadImage("1small.jpg");
- small[3] = loadImage("2small.jpg");
- small[4] = loadImage("3small.jpg");
- small[5] = loadImage("4small.jpg");
- small[6] = loadImage("5small.jpg");
- //
- }
- void draw()
- {
- background (255);
- // use for loop here
- image (small[1], 100, 20);
- image (small[2], 200, 20);
- image (small[3], 300, 20);
- image (small[4], 400, 20);
- image (small[5], 500, 20);
- image (small[6], 600, 20);
- //
- if (indexBigImage != -1)
- {
- image (big[indexBigImage], 60, 120);
- }
- //
- if (mouseX>100&&mouseX<180&&mouseY>10&&mouseY<80)
- {
- indexBigImage=1;
- }
- else if (mouseX>200&&mouseX<280&&mouseY>10&&mouseY<80)
- {
- indexBigImage = 2;
- }
- else
- {
- indexBigImage = -1;
- } // else
- //
- } // func
- //