Skip to content
Snippets Groups Projects
Commit 3863f015 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Revert "Merge branch 'feature-pursuit_devel' into 'V3.2.1'

This reverts commit 62f6915c, reversing
changes made to 76749275.
parent 62f6915c
Branches
Tags
No related merge requests found
......@@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.TimeUtils;
import java.util.LinkedHashMap;
......@@ -33,47 +32,10 @@ public class DragAndRotateActorListener extends InputListener {
private float actorOriginalRotation;
private boolean performingAction;
private boolean pieceAnimationDone;
private Touch lastTouch, newTouch;
private RotateAndMovePieceInPosition pieceTranslationAction;
private LinkedHashMap<Integer, Point> activePointers;
class Touch {
public static final float TIME_BETWEEN_TOUCHES = 100;
public static final float TIME_BETWEEN_TAPS = 600;
private long time;
private Actor touchedActor;
public Touch(Actor touchedActor, long time) {
this.touchedActor = touchedActor;
this.time = time;
}
public Actor getTouchedActor() {
return touchedActor;
}
public long getTime() {
return time;
}
public boolean isTap(Touch touch) {
return controlIfSame(touch, TIME_BETWEEN_TOUCHES);
}
private boolean controlIfSame(Touch secondTouch, float time) {
return getTouchedActor().equals(secondTouch.getTouchedActor()) && Math.abs(secondTouch.getTime() - getTime()) < time;
}
public boolean isDoubleTap(Touch touch) {
return controlIfSame(touch, TIME_BETWEEN_TAPS);
}
}
public DragAndRotateActorListener(IOnRotationFinished iOnRotationFinished) {
this.iOnRotationFinished = iOnRotationFinished;
activePointers = new LinkedHashMap<Integer, Point>();
......@@ -93,11 +55,6 @@ public class DragAndRotateActorListener extends InputListener {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (pointer==0) { //one finger
newTouch = new Touch(((Grid) parentActor).pieceAtPoint(x, y), TimeUtils.millis()); //save touched piece and time
if (lastTouch != null && newTouch.getTime() - lastTouch.getTime() > Touch.TIME_BETWEEN_TAPS) //check if new touch is
lastTouch = null;
}
if (button != 1) {
activePointers.put(pointer, new Point(x, y));
}
......@@ -157,25 +114,6 @@ public class DragAndRotateActorListener extends InputListener {
@Override
public void touchUp(InputEvent event, final float x, final float y, int pointer, int button) {
if (pointer==0) {
Touch tempTouch = new Touch(((Grid) parentActor).pieceAtPoint(x, y), TimeUtils.millis());
if (newTouch != null) {
boolean tapped = tempTouch.isTap(newTouch);
if (tapped) {
if (lastTouch != null) {
if (tempTouch.isDoubleTap(lastTouch)) {
Actor actorToRotate = lastTouch.getTouchedActor();
actorToRotate.addAction(Actions.rotateTo(actorToRotate.getRotation()-90, 0.5f));
rotated(actorToRotate.getRotation() - 90, actorToRotate);
} else {
lastTouch = new Touch(draggedActor, (tempTouch.getTime() + newTouch.getTime()) / 2); //not double - save least touch
}
} else {
lastTouch = new Touch(draggedActor, (tempTouch.getTime() + newTouch.getTime()) / 2);
}
}
}
}
if (button != 1) {
if (draggedActor != null && !performingAction && activePointers.size()>=1) {
//storing original fingers positions and deciding which finger was released
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment