I am having trouble making a button function. The problem that I am having is that the “Value” that I put in the function won’t change to “ChangeToThisValue” if the conditions are correct. For example if conditions are correct then Show equals 1. Aka RectanglarButton(50, 0, 50, height, Show, 1);
Not sure how to solve this any help is appreciated.
Here’s the code.
int Show;
void setup() {
size(200, 200);
}
void draw() {
if (Show == 0) {
background(173, 129, 129);
} else if (Show == 1) {
background(200);
} else if (Show == 2) {
background(0);
}
RectanglarButton(0, 0, 50, height, Show, 0);
RectanglarButton(50, 0, 50, height, Show, 1);
RectanglarButton(100, 0, 50, height, Show, 2);
}
void RectanglarButton(float PosX, float PosY, float Width, float Height, int Value, int ChangeToThisValue) {
fill(255);
if (mouseX > PosX && mouseX < PosX + Width && mouseY > PosY && mouseY < PosY + Height) {
if (mousePressed) {
fill(215);
Value = ChangeToThisValue;
}
fill(235);
}
rect(PosX, PosY, Width, Height);
}