small blackout - how drag existing rect, xValue
in
Programming Questions
•
1 year ago
hello,
I encounter a small blackout here.
What is the new x-Value when I drag an existing rect?
The dragging and clicking is no problem but I fail to find the right formula for the new x-value.
I want to click the existing rect and then move the mouse and when I drag it, the rect slowly moves accordingly.
At the moment though it jumps because I got the new values wrong...
This is what I got in mouseDragged()
- float m = map(mouseX-initialMouseValue.x, 0, width, -200, 200);
- rectPos.x = m; // use map
initialMouseValue.x being a value stored at the beginning of the dragging in mousePressed() - it is the x-value of the mouse at the beginning of the dragging.
Thanks!
Greetings,
Chrisir
1