We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello world! So, I'm new to processing and so I've been trying to make a button as part of a college assignment thing, but it won't work for some reason. Here's the relevant code for you guys to see if I did anything stupidly wrong. It works, but the button doesn't do anything:
void mouseClicked()
{
if (mouseX>218 && mouseX<218+buttonWidth && mouseY>350 && mouseY<buttonHeight)
{
fill(190,200,0);
rect(218,350,buttonWidth,buttonHeight);
}
}
(Also, I did declare buttonWidth and buttonHeight before in the code. This is only a segment of it).
If any of you can help me, I'd appreciate it!
Answers
How tall is this button? If it's less than 350 pixels tall, you have a problem.
https://Forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
http://JeffreyThompson.org/collision-detection/point-rect.php
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9eDRvB4LRmLrr
you forgot 350 once
the rect will only flash briefly though
to have it longer you would set a boolean variable here at the mouse button evaluation and evaluate that boolean in draw and draw the rect there