/* buttons click through the image arrays they could click through more arrays, you just have to add them and more buttons if you want */ Button button, button2, button3; //declare button objects PImage[] p1 = new PImage[7]; PImage[] p2 = new PImage[7]; PImage[] p3 = new PImage[3]; int clickCount, clickCount2, clickCount3; void setup() { size(360, 250); clickCount = 0; clickCount2 = 0; clickCount3 = 0; //instantiate button opbjects: button = new Button(25, 10, 50, //x, y, size color(204), color(255), color(0)); button2 = new Button(140, 10, 50, color(204), color(255), color(0)); button3 = new Button(265, 10, 50, color(204), color(255), color(0)); p1[0] = loadImage("1a.jpg"); p1[1] = loadImage("1b.jpg"); p1[2] = loadImage("1c.jpg"); p1[3] = loadImage("2a.jpg"); p1[4] = loadImage("2b.jpg"); p1[5] = loadImage("2c.jpg"); p1[6] = loadImage("3a.jpg"); p2[0] = loadImage("3b.jpg"); p2[1] = loadImage("3c.jpg"); p2[2] = loadImage("4a.jpg"); p2[3] = loadImage("4b.jpg"); p2[4] = loadImage("5a.jpg"); p2[5] = loadImage("5b.jpg"); p2[6] = loadImage("5c.jpg"); p3[0] = loadImage("6a.jpg"); p3[1] = loadImage("6b.jpg"); p3[2] = loadImage("6c.jpg"); } void draw() { background(104, 0, 134); stroke(255); fill(0, 0, 245); rect(10,110, 99, 99);//they are behind images, not compulsory! rect(130,110, 99, 99); rect(250, 110, 99, 99); if(clickCount < p1.length) { image(p1[clickCount], 10,110, 100, 100); } else if (clickCount > p1.length){ clickCount = 0; } if(clickCount2 < p2.length) { image(p2[clickCount2], 130, 110, 100, 100); } else if (clickCount2 > p2.length){ clickCount2 = 0; } if(clickCount3 < p3.length) { image(p3[clickCount3], 250,110, 100, 100); //x, y, size } else if (clickCount3 > p3.length){ clickCount3 = 0; } button.update(); button.display(); button2.update(); button2.display(); button3.update(); button3.display(); } void mousePressed() { if( button.press()) { print("button 1 "); clickCount++; } else if( button2.press()) { print("buton 2 "); clickCount2++; } else if( button3.press()) { print("button 3 "); clickCount3++; } } void mouseReleased() { button.release(); button2.release(); button3.release(); }