I override the pan
method in ActorGestureListener
to implement dragging actors in libgdx (scene2d).
When I move individual pieces on a board they move smoothly, but when moving the whole board, the x and y coordinates that is sent to pan is "jumping", and in an increasingly amount the longer it is dragged.
These are an example of the deltaY coordinates sent to pan when dragging smoothly downwards:
1.1156368
-0.13125038
-1.0500145
0.98439217
-1.0500202
0.91877174
-0.984396
0.9187679
-0.98439026
0.9187641
-0.13125038
This is how I move the camera:
public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
cam.translate(-deltaX, -deltaY);
I have been using both the delta values sent to pan and the real position values, but similar results. And since it is the coordinates that are wrong, it doesn't matter whether I move the board itself or the camera.
What could the cause be for this and what is the solution?
EDIT
When I move camera only half the delta-values, it moves smoothly but only at half the speed of the mouse pointer:
cam.translate(-deltaX / 2, -deltaY / 2);
It seems like the moving of camera or board affects the mouse input coordinates. How can I drag at "mouse speed" and still get smooth movements?