How do you detect a double tap drag? I am making a game similar to bejeweled, and would like to detect this. In my current implementation, I was able to get the swipe effects. I would also like to detect the double tap drag effect for a different functionality in the game.
CODE:
@Override
public boolean onTouch(MotionEvent e, int scaledX, int scaledY) {
if (e.getAction() == MotionEvent.ACTION_DOWN && board.touchBoard(scaledX, scaledY) ) {
recentTouchY = scaledY;
recentTouchX = scaledX;
board.whichCell(scaledX,scaledY);
touchedCell = board.whichCellTouched(scaledX,scaledY);
//board.swapClearShape(touchedCell.getOffX(),touchedCell.getOffY());
} else if (e.getAction() == MotionEvent.ACTION_UP) { //NEED TO ADD IF TOUCH BOARD AREA
//swipe event
if (scaledX - recentTouchX < -25) {
System.out.println("SWAPPED LEFT");
Assets.playSound(Assets.swapSound);
board.setSwapLeft(true);
}
else if (scaledX - recentTouchX > 25) {
System.out.println("SWAPPED RIGHT");
Assets.playSound(Assets.swapSound);
board.setSwapRight(true);
}
//swap down
else if(scaledY- recentTouchY > 25){
System.out.println("SWAPPED DOWN");
Assets.playSound(Assets.swapSound);
board.setSwapDown(true);
}
//swap up
else if(scaledY- recentTouchY < -25){
System.out.println("SWAPPED UP");
Assets.playSound(Assets.swapSound);
board.setSwapUp(true);
}
}
return true;
}
I am not looking for two finger drag, rather one touch followed by and another touch then drag