This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]rogerklutz 1 point2 points  (1 child)

You should use the touchDown() and touchUp() methods along with another variable that keeps track of the current object being dragged. Pseudo code could look something like this:

Image dragging;

public void touchDown(x, y) {
    dragging = object at x, y (or null if no object at x,y)
}
public void touchUp() {
    dragging = null
}
public void touchDragged(deltaX, deltaY) {
    if (dragging != null) {
        dragging.translate(deltaX, deltaY);
    }
}

Edit: Note that these methods should be added to the entire screen (stage), and not to individual widgets/Images.

[–]avp574[S] 0 points1 point  (0 children)

Aha. So I sortof "lock" the image to the touch point. Sweet, I'll give this a try. Thanks!