Hey all, just a question on how to get the rectangles in this array to disappear when I click on one of them. I presume it's in the alpha section but I'm stuck as to how to implement it. I've tried putting a mousepressed within the for statement but it doesn't change it.
- menu sp;
- int [] menuposy = {
- 0, 10, 20, 30, 40, 50, 60, 70, 80,
- };
- color[] boxcolour= {
- color(10, 0, 0),
- color(50, 0, 0),
- color(60, 0, 0),
- color(90, 0, 0),
- color(110, 0, 0),
- color(189, 0, 0),
- color(123, 0, 0),
- color(234, 0, 0),
- color(120, 0, 0),
- };
- class menu {
- void menuitem() {
- for (int i = 0;i < menuposy.length;i++) {
- if (mouseX > 10 && mouseX < 40 && mouseY > menuposy[i] && mouseY < menuposy[i]+10) {
- fill (255);
- rect(10, menuposy[i], 30, 10);
- }
- else {
- fill (boxcolour[i]);
- }
- rect(10, menuposy[i], 30, 10);
- }
- }
- }
- menu[] menus;
- void setup() {
- size(100, 100);
- sp = new menu();
- }
- void draw() {
- sp.menuitem();
- }
1