We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi,
I'm trying to check if my user moved his mouse since the last time he pressed, but the pmouseX is always the same as my mouseX. In the reference it says "inside mouse events, they update each time the event is called", so the previous position should be updated to pmouseX / pmouseY when i click again right? Atm it just gives me the same number. here's the code:
void mousePressed()
{
println("old x: " + pmouseX + " - new x: " + mouseX);
}
Answers
The problem is that you're only tying into one event. There are many other events: mouseMoved and mouseDragged for example.
So
pmouseX
andpmouseY
don't contain the x and y values of the last mousePressed() function, they return the x and y values of the last mouse event, whatever that was (probably mouseMoved). And since you just moved the mouse to the location you clicked, that will always be the same asmouseX
andmouseY
.If you want to keep track of the last location you clicked, you'll have to store that in your own variables.
Oh Gotcha! Makes sense.