@Override protected void onDrag(Touch t) { camera.target = null; if (pinching) { float curSpan = PointF.distance(touch.current, another.current); camera.zoom( GameMath.gate(PixelScene.minZoom, startZoom * curSpan / startSpan, PixelScene.maxZoom)); } else { if (!dragging && PointF.distance(t.current, t.start) > dragThreshold) { dragging = true; lastPos.set(t.current); } else if (dragging) { camera.scroll.offset(PointF.diff(lastPos, t.current).invScale(camera.zoom)); lastPos.set(t.current); } } }
@Override protected void onTouchDown(Touch t) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown(t); return; } pinching = true; another = t; startSpan = PointF.distance(touch.current, another.current); startZoom = camera.zoom; dragging = false; } }