We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I am trying to make a button which gets enabled when mouse is over the button and gets disable when mouse goes over the button again. Actually what's happening here is when I bring my mouse over the ellipse it keeps switching between the enable and disable mode and doesn't stop until I move my cursor. I want this to be happen once at a time.
boolean flag=false;
int x, y, radius=100;
void setup() {
size(400, 400);
x = width/2;
y = width/2;
}
void draw() {
background(-1);
if (dist(mouseX, mouseY, x, y)<radius/2) {
flag=!flag;
}
if (flag) {
fill(0, 255, 0);
}
else {
fill(255, 0, 0);
}
ellipse(x, y, radius, radius);
}
Answers
maybe this?
Exactly what I wanted ........ thanks