float dragActorX = 14, dragActorY = -20;
long dragStartTime;
int dragTime = 250;
+ boolean isDragging = false;
+ Object dragSyncObj = new Object();
+ int activePointer;
public void addSource (final Source source) {
DragListener listener = new DragListener() {
public void dragStart (InputEvent event, float x, float y, int pointer) {
+ synchronized (dragSyncObj) {
+ if (isDragging) {
+ event.stop();
+ return;
+ }
+
+ isDragging = true;
+ activePointer = pointer;
+ }
+
dragStartTime = System.currentTimeMillis();
payload = source.dragStart(event, getTouchDownX(), getTouchDownY(), pointer);
event.stop();
public void drag (InputEvent event, float x, float y, int pointer) {
if (payload == null) return;
+ if (pointer != activePointer) return;
+
Stage stage = event.getStage();
Touchable dragActorTouchable = null;
public void dragStop (InputEvent event, float x, float y, int pointer) {
if (payload == null) return;
+ if (pointer != activePointer) return;
+
+ synchronized (dragSyncObj) {
+ isDragging = false;
+ }
+
if (System.currentTimeMillis() - dragStartTime < dragTime) isValidTarget = false;
if (dragActor != null) dragActor.remove();
if (isValidTarget) {