We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey everyone. I'm extremely new to processing, but am trying to make a ball that blinks when you click on it. It's required that this function returns true or false but I don't know how to use boolean functions in OOP. It seems that I've tried everything. This is what I have so far. How do I implement this in setup() or draw()? Help!
boolean Clicked (float x, float y, float distance){
distance = sq((mouseX - x)) + sq((mouseY - y);
if (distance <= radius*radius)
// make the ball that was click on blink
// if clicked on again stop blinking
}
Answers
This concept does not agree with what the function returns. Either the function does something (make a previously defined ball blink - ball being a member object of your class) which will not required to return a boolean value. On the other hand, if it returns a boolean value, some other part of the code will handle the blinking. You are better off if you post all your code, or even better, a small sample code showing your concept and what you have so far. You can also check the following example showing a button class. The code demonstrates hover action over the button as well as click action. This example might be relevant to your request.
Kf