Cedric
Re: button actions
Reply #4 - Apr 7th , 2009, 5:05pm
NoahBuddy is right, a button class would be the only good way. But anyway, i worked on your code if you wanna keep it that way. First, you dont need all boolean stuff, just check within if funktion. Dont use else... just different "ifs" best way for a circle is to check the distance between the mouse position and the circle origin. if it is <radius its withing the circle. hmm guess thats it, but you should take a look at the class anyway: void setup(){ size(300, 300); smooth(); } void draw(){ background(0); fill(200); fill(#555555); ellipse(50, 50, 45, 45); ellipse(50, 150, 45, 45); ellipse(50, 250, 45, 45); ellipse(150, 50, 45, 45); ellipse(150, 150, 45, 45); ellipse(150, 250, 45, 45); ellipse(250, 50, 45, 45); ellipse(250, 150, 45, 45); ellipse(250, 250, 45, 45); if(dist(mouseX,mouseY,50,50)<25) { fill(#FF0000); ellipse(50, 50, 50, 50); } if (dist(mouseX,mouseY,150,50)<25){ fill(#00FFFF); ellipse(150, 50, 50, 50); } if (dist(mouseX,mouseY,250,50)<25){ fill(#FF0000); ellipse(250, 50, 50, 50); } if (dist(mouseX,mouseY,50,150)<25){ fill(#FF0000); ellipse(50, 150, 50, 50); } if (dist(mouseX,mouseY,150,150)<25){ fill(#00FFFF); ellipse(150, 150, 50, 50); } if (dist(mouseX,mouseY,250,150)<25){ fill(#FF0000); ellipse(250, 150, 50, 50); } if (dist(mouseX,mouseY,50,250)<25){ fill(#FF0000); ellipse(50, 250, 50, 50); } if (dist(mouseX,mouseY,150,250)<25){ fill(#00FFFF); ellipse(150, 250, 50, 50); } if (dist(mouseX,mouseY,250,250)<25){ fill(#FF0000); ellipse(250, 250, 50, 50); } }