InputProcessor implementation that detects gestures (tap, long press, fling, pan, zoom, pinch) and hands them to a
GestureListener.
| Modifier and Type | Class and Description |
|---|---|
| public static class | GestureDetector.
Derrive from this if you only want to implement a subset of |
| public static interface | GestureDetector.
Register an instance of this class with a |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Vector2 | |
| private final Vector2 | |
| private boolean | |
| private int | |
| private int | |
| private long | |
| private float | |
| private float | |
| pack-priv final GestureDetector. | |
| pack-priv boolean | |
| private float | |
| private final Timer. | |
| private long | |
| private boolean | |
| private boolean | |
| pack-priv Vector2 | |
| private final Vector2 | |
| private int | |
| private long | |
| private float | |
| private float | |
| private float | |
| private float | |
| private long | |
| private final GestureDetector. |
| Access | Constructor and Description |
|---|---|
| public | GestureDetector(GestureDetector.
Creates a new GestureDetector with default values: halfTapSquareSize=20, tapCountInterval=0.4f, longPressDuration=1.1f, maxFlingDelay=Integer.MAX_VALUE. |
| public | GestureDetector(float
half width in pixels of the square around an initial touch event, see
halfTapSquareSize, float GestureListener#tap(float, float, int, int).time in seconds that must pass for two touch down/up sequences to be detected as consecutive taps. tapCountInterval, float time in seconds that must pass for the detector to fire a
longPressDuration, float GestureListener#longPress(float, float) event.no fling event is fired when the time in seconds the finger was dragged is larger than this, see
maxFlingDelay, GestureDetector.GestureListener#fling(float, float, int)
|
| public | GestureDetector(float
half width in pixels of the rectangle around an initial touch event, see
halfTapRectangleWidth, float GestureListener#tap(float, float, int, int).half height in pixels of the rectangle around an initial touch event, see
halfTapRectangleHeight, float GestureListener#tap(float, float, int, int).time in seconds that must pass for two touch down/up sequences to be detected as consecutive taps. tapCountInterval, float time in seconds that must pass for the detector to fire a
longPressDuration, float GestureListener#longPress(float, float) event.no fling event is fired when the time in seconds the finger was dragged is larger than this, see
maxFlingDelay, GestureDetector.GestureListener#fling(float, float, int)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public boolean | isLongPressed()
Returns: whether the user touched the screen long enough to trigger a long press event. |
| public boolean | isLongPressed(float duration)
Returns: whether the user touched the screen for as much or more than the given duration. |
| public boolean | |
| private boolean | |
| public void | |
| public void | |
| public void | |
| public void | setTapCountInterval(float
time in seconds that must pass for two touch down/up sequences to be detected as consecutive
taps. tapCountInterval)
|
| public void | |
| public void | |
| public boolean | touchCancelled(int screenX, int screenY, int pointer, int button)
Overrides com. Implements com. Called when the touch gesture is cancelled. |
| public boolean | touchDown(int x, int y, int pointer, int button)
Overrides com. Implements com. Called when the screen was touched or a mouse button was pressed. |
| public boolean | |
| public boolean | touchDragged(int x, int y, int pointer)
Overrides com. Implements com. Called when a finger or the mouse was dragged. |
| public boolean | |
| public boolean | touchUp(int x, int y, int pointer, int button)
Overrides com. Implements com. Called when a finger was lifted or a mouse button was released. |
| public boolean |
| initialPointer1 | back to summary |
|---|---|
| private final Vector2 initialPointer1 | |
| initialPointer2 | back to summary |
|---|---|
| private final Vector2 initialPointer2 | |
| inTapRectangle | back to summary |
|---|---|
| private boolean inTapRectangle | |
| lastTapButton | back to summary |
|---|---|
| private int lastTapButton | |
| lastTapPointer | back to summary |
|---|---|
| private int lastTapPointer | |
| lastTapTime | back to summary |
|---|---|
| private long lastTapTime | |
| lastTapX | back to summary |
|---|---|
| private float lastTapX | |
| lastTapY | back to summary |
|---|---|
| private float lastTapY | |
| listener | back to summary |
|---|---|
| pack-priv final GestureDetector. | |
| longPressFired | back to summary |
|---|---|
| pack-priv boolean longPressFired | |
| longPressSeconds | back to summary |
|---|---|
| private float longPressSeconds | |
| longPressTask | back to summary |
|---|---|
| private final Timer. | |
| maxFlingDelay | back to summary |
|---|---|
| private long maxFlingDelay | |
| panning | back to summary |
|---|---|
| private boolean panning | |
| pinching | back to summary |
|---|---|
| private boolean pinching | |
| pointer1 | back to summary |
|---|---|
| pack-priv Vector2 pointer1 | |
| pointer2 | back to summary |
|---|---|
| private final Vector2 pointer2 | |
| tapCount | back to summary |
|---|---|
| private int tapCount | |
| tapCountInterval | back to summary |
|---|---|
| private long tapCountInterval | |
| tapRectangleCenterX | back to summary |
|---|---|
| private float tapRectangleCenterX | |
| tapRectangleCenterY | back to summary |
|---|---|
| private float tapRectangleCenterY | |
| tapRectangleHeight | back to summary |
|---|---|
| private float tapRectangleHeight | |
| tapRectangleWidth | back to summary |
|---|---|
| private float tapRectangleWidth | |
| touchDownTime | back to summary |
|---|---|
| private long touchDownTime | |
| tracker | back to summary |
|---|---|
| private final GestureDetector. | |
| GestureDetector | back to summary |
|---|---|
| public GestureDetector(GestureDetector. Creates a new GestureDetector with default values: halfTapSquareSize=20, tapCountInterval=0.4f, longPressDuration=1.1f, maxFlingDelay=Integer.MAX_VALUE. | |
| GestureDetector | back to summary |
|---|---|
public GestureDetector(float halfTapSquareSize, float tapCountInterval, float longPressDuration, float maxFlingDelay, GestureDetector.
| |
| GestureDetector | back to summary |
|---|---|
public GestureDetector(float halfTapRectangleWidth, float halfTapRectangleHeight, float tapCountInterval, float longPressDuration, float maxFlingDelay, GestureDetector.
| |
| cancel | back to summary |
|---|---|
| public void cancel() No further gesture events will be triggered for the current touch, if any. | |
| invalidateTapSquare | back to summary |
|---|---|
| public void invalidateTapSquare() The tap square will no longer be used for the current touch. | |
| isLongPressed | back to summary |
|---|---|
public boolean isLongPressed()
| |
| isLongPressed | back to summary |
|---|---|
public boolean isLongPressed(float duration)
| |
| isPanning | back to summary |
|---|---|
| public boolean isPanning() | |
| isWithinTapRectangle | back to summary |
|---|---|
| private boolean isWithinTapRectangle(float x, float y, float centerX, float centerY) | |
| reset | back to summary |
|---|---|
| public void reset() | |
| setLongPressSeconds | back to summary |
|---|---|
| public void setLongPressSeconds(float longPressSeconds) | |
| setMaxFlingDelay | back to summary |
|---|---|
| public void setMaxFlingDelay(long maxFlingDelay) | |
| setTapCountInterval | back to summary |
|---|---|
public void setTapCountInterval(float tapCountInterval)
| |
| setTapRectangleSize | back to summary |
|---|---|
| public void setTapRectangleSize(float halfTapRectangleWidth, float halfTapRectangleHeight) | |
| setTapSquareSize | back to summary |
|---|---|
| public void setTapSquareSize(float halfTapSquareSize) | |
| touchCancelled | back to summary |
|---|---|
| public boolean touchCancelled(int screenX, int screenY, int pointer, int button) Overrides com. Implements com. Doc from com. Called when the touch gesture is cancelled. Reason may be from OS interruption to touch becoming a large surface such as
the user cheek). Relevant on Android and iOS only. The button parameter will be
| |
| touchDown | back to summary |
|---|---|
| public boolean touchDown(int x, int y, int pointer, int button) Overrides com. Implements com. Doc from com. Called when the screen was touched or a mouse button was pressed. The button parameter will be
| |
| touchDown | back to summary |
|---|---|
| public boolean touchDown(float x, float y, int pointer, int button) | |
| touchDragged | back to summary |
|---|---|
| public boolean touchDragged(int x, int y, int pointer) Overrides com. Implements com. Doc from com. Called when a finger or the mouse was dragged.
| |
| touchDragged | back to summary |
|---|---|
| public boolean touchDragged(float x, float y, int pointer) | |
| touchUp | back to summary |
|---|---|
| public boolean touchUp(int x, int y, int pointer, int button) Overrides com. Implements com. Doc from com. Called when a finger was lifted or a mouse button was released. The button parameter will be
| |
| touchUp | back to summary |
|---|---|
| public boolean touchUp(float x, float y, int pointer, int button) | |
GestureListener.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | fling(float velocityX, float velocityY, int button)
Implements com. Called when the user dragged a finger over the screen and lifted it. |
| public boolean | longPress(float x, float y)
Implements com.
|
| public boolean | pan(float x, float y, float deltaX, float deltaY)
Implements com. Called when the user drags a finger over the screen. |
| public boolean | panStop(float x, float y, int pointer, int button)
Implements com. Called when no longer panning. |
| public boolean | |
| public void | pinchStop()
Implements com. Called when no longer pinching. |
| public boolean | tap(float x, float y, int count, int button)
Implements com. Called when a tap occured. |
| public boolean | touchDown(float x, float y, int pointer, int button)
Implements com.
|
| public boolean | zoom(float initialDistance, float distance)
Implements com. Called when the user performs a pinch zoom gesture. |
| GestureAdapter | back to summary |
|---|---|
| public GestureAdapter() | |
| fling | back to summary |
|---|---|
| public boolean fling(float velocityX, float velocityY, int button) Implements com. Doc from com. Called when the user dragged a finger over the screen and lifted it. Reports the last known velocity of the finger in pixels per second.
| |
| longPress | back to summary |
|---|---|
| public boolean longPress(float x, float y) Implements com.
| |
| pan | back to summary |
|---|---|
| public boolean pan(float x, float y, float deltaX, float deltaY) Implements com. Doc from com. Called when the user drags a finger over the screen.
| |
| panStop | back to summary |
|---|---|
| public boolean panStop(float x, float y, int pointer, int button) Implements com. Doc from com. Called when no longer panning.
| |
| pinch | back to summary |
|---|---|
| public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) Implements com. Doc from com. Called when a user performs a pinch zoom gesture. Reports the initial positions of the two involved fingers and their current positions.
| |
| pinchStop | back to summary |
|---|---|
| public void pinchStop() Implements com. Doc from com. Called when no longer pinching.
| |
| tap | back to summary |
|---|---|
| public boolean tap(float x, float y, int count, int button) Implements com. Doc from com. Called when a tap occured. A tap happens if a touch went down on the screen and was lifted again without moving outside
of the tap square. The tap square is a rectangular area around the initial touch position as specified on construction
time of the
| |
| touchDown | back to summary |
|---|---|
| public boolean touchDown(float x, float y, int pointer, int button) Implements com.
| |
| zoom | back to summary |
|---|---|
| public boolean zoom(float initialDistance, float distance) Implements com. Doc from com. Called when the user performs a pinch zoom gesture. The original distance is the distance in pixels when the gesture started.
| |
GestureDetector to receive gestures such as taps, long presses, flings,
panning or pinch zooming. Each method returns a boolean indicating if the event should be handed to the next listener (false
to hand it to the next listener, true otherwise).
| Modifier and Type | Method and Description |
|---|---|
| public boolean | fling(float
velocity on x in seconds velocityX, float velocity on y in seconds velocityY, int button)Called when the user dragged a finger over the screen and lifted it. |
| public boolean | |
| public boolean | pan(float x, float y, float
the difference in pixels to the last drag event on x. deltaX, float the difference in pixels to the last drag event on y. deltaY)Called when the user drags a finger over the screen. |
| public boolean | |
| public boolean | |
| public void | |
| public boolean | |
| public boolean | |
| public boolean | zoom(float
distance between fingers when the gesture started. initialDistance, float current distance between fingers. distance)Called when the user performs a pinch zoom gesture. |
| fling | back to summary |
|---|---|
| public boolean fling(float velocityX, float velocityY, int button) Called when the user dragged a finger over the screen and lifted it. Reports the last known velocity of the finger in pixels per second.
| |
| longPress | back to summary |
|---|---|
| public boolean longPress(float x, float y) | |
| pan | back to summary |
|---|---|
| public boolean pan(float x, float y, float deltaX, float deltaY) Called when the user drags a finger over the screen.
| |
| panStop | back to summary |
|---|---|
| public boolean panStop(float x, float y, int pointer, int button) Called when no longer panning. | |
| pinch | back to summary |
|---|---|
| public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) Called when a user performs a pinch zoom gesture. Reports the initial positions of the two involved fingers and their current positions. | |
| pinchStop | back to summary |
|---|---|
| public void pinchStop() Called when no longer pinching. | |
| tap | back to summary |
|---|---|
| public boolean tap(float x, float y, int count, int button) Called when a tap occured. A tap happens if a touch went down on the screen and was lifted again without moving outside
of the tap square. The tap square is a rectangular area around the initial touch position as specified on construction
time of the
| |
| touchDown | back to summary |
|---|---|
| public boolean touchDown(float x, float y, int pointer, int button) | |
| zoom | back to summary |
|---|---|
| public boolean zoom(float initialDistance, float distance) Called when the user performs a pinch zoom gesture. The original distance is the distance in pixels when the gesture started.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv float | |
| pack-priv float | |
| pack-priv long | |
| pack-priv float | |
| pack-priv float | |
| pack-priv long[] | |
| pack-priv float[] | |
| pack-priv float[] | |
| pack-priv int | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private float | |
| private long | |
| private float | |
| public float | |
| public float | |
| public void | |
| public void |
| deltaX | back to summary |
|---|---|
| pack-priv float deltaX | |
| deltaY | back to summary |
|---|---|
| pack-priv float deltaY | |
| lastTime | back to summary |
|---|---|
| pack-priv long lastTime | |
| lastX | back to summary |
|---|---|
| pack-priv float lastX | |
| lastY | back to summary |
|---|---|
| pack-priv float lastY | |
| meanTime | back to summary |
|---|---|
| pack-priv long[] meanTime | |
| meanX | back to summary |
|---|---|
| pack-priv float[] meanX | |
| meanY | back to summary |
|---|---|
| pack-priv float[] meanY | |
| numSamples | back to summary |
|---|---|
| pack-priv int numSamples | |
| sampleSize | back to summary |
|---|---|
| pack-priv int sampleSize | |
| VelocityTracker | back to summary |
|---|---|
| pack-priv VelocityTracker() | |
| getAverage | back to summary |
|---|---|
| private float getAverage(float[] values, int numSamples) | |
| getAverage | back to summary |
|---|---|
| private long getAverage(long[] values, int numSamples) | |
| getSum | back to summary |
|---|---|
| private float getSum(float[] values, int numSamples) | |
| getVelocityX | back to summary |
|---|---|
| public float getVelocityX() | |
| getVelocityY | back to summary |
|---|---|
| public float getVelocityY() | |
| start | back to summary |
|---|---|
| public void start(float x, float y, long timeStamp) | |
| update | back to summary |
|---|---|
| public void update(float x, float y, long currTime) | |