We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
Im doing some simple noob stuf where I have an event (mouseClicked) that does something only if the mouse has moved to different coordinates.
So, at the beginning of the sketch I declare mouseXLog and MouseYLog but dont initizalize them
int mouseXLog,
mouseYLog;
Then in my event I have:
void mouseClicked() {
if ([...]mouseXLog < mouseX || mouseXLog > mouseX || mouseYLog < mouseY || mouseYLog > mouseY)
{
nrOfClicks++;
mouseXLog = mouseX;
mouseYLog = mouseY;
}
And this works. My questions is:
How can "mouseXLog < mouseX || mouseXLog > mouseX || mouseYLog < mouseY || mouseYLog > mouseY" evaluate to true when it is initialized for the first time after the event?
Cheers,
Answers
https://Docs.Oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
btw, you can simplify
mouseXLog < mouseX || mouseXLog > mouseX
asmouseXLog != mouseX
. As you're counting nrOfClicks anyway, you can also check whether that is zero for the first click.