I’m new to processing and this should be really easy to solve but I’m kind of stuck. So basicially, this is a snippet of my programm.
What I want to achieve is that if I click on a button, it shows another picture and if I click on it again, the picture should disappear. I’ve looked through google and other forums but I’m not really sure on what to look for since the results for “boolean” and “mouse clicked” and so on, vary and can be quite extensive.
I’m sorry if this is really obvious…
Problem: I’m not sure how to include the “else”, so that if I click on the designated area, it turns off.
I tried if else (mousePressed) and then the mouse locations, and noticed I have to include another “if” to get the “lightbutton1 = false” in but it didn’t work.
void draw ()
{
image(BG1,0,0);
if(lightbutton1) {
image(light,0,0); }
}
void mousePressed () {
if (mouseX > 720 && mouseY < 477 && mouseX < 800 && mouseY > 420) {
lightbutton1 = false;
}
else
{
lightbutton1 = true;
}
}