@Override protected void updateState (GestureNode node) { switch (node.type) { case PAUSE: setState(State.UNQUALIFIED); break; case MOVE: Point start = _startPoints.get(node.touch.id); if (start == null) Log.log.warning("No start for a moved touch", "id", node.touch.id); else if (start.distance(node.location) > MOVE_THRESHOLD) setState(State.UNQUALIFIED); break; case CANCEL: setState(State.UNQUALIFIED); break; case START: _startPoints.put(node.touch.id, node.location); int size = _startPoints.size(); if (size > _touches) setState(State.UNQUALIFIED); else if (size == _touches && _greedy) setState(State.GREEDY); break; case END: // when any touch ends, we either move to unqualified if we didn't have enough touches // or complete if we did. setState(_startPoints.size() == _touches ? State.COMPLETE : State.UNQUALIFIED); break; } }
if (current.distance(startLoc) < _onAxisThreshold) return;
@Override public void onEnd (Pointer.Interaction iact) { // just dispatch a click if the pointer didn't move very far if (_maxDeltaSq < maxClickDeltaSq()) { clicked.emit(iact.event); return; } // if not, maybe impart some velocity float dragTime = (float)(iact.event.time - _prevStamp); if (dragTime > 0) { Point delta = new Point(_cur.x - _prev.x, _cur.y - _prev.y); Point dragVel = delta.mult(1 / dragTime); float dragSpeed = dragVel.distance(0, 0); if (dragSpeed > maxFlickSpeed) { dragVel.multLocal(maxFlickSpeed / dragSpeed); dragSpeed = maxFlickSpeed; } _vel.set(dragVel); _vel.multLocal(flickXfer); float sx = Math.signum(_vel.x), sy = Math.signum(_vel.y); _accel.x = -sx * friction; _accel.y = -sy * friction; } }