Touch
With the Touch class Listeners can be registered, which notice when a new Touch has been started (i.e. a finger has been added), if a finger has moved, or if a Touch has stopped, etc.
Example:
// Register the listeners
final Touch touch = new Touch(this);
// Outputs the coordinates of the touches
final Consumer<List<TouchObject>> touchPrinter = touches -> {
touches.forEach(t -> {
System.out.println("x: " + t.getScreenX() + ", y: " + t.getScreenY());
});
};
final Registration listenerRegistration = touch.addTouchListener(event -> {
final List<TouchObject> touches = event.getChangedTouches();
switch(event.getType()) {
case TOUCH_START:
System.out.println("Neuer Touch gestartet @");
break;
case TOUCH_END:
System.out.println("Touch wurde beendet @");
break;
case TOUCH_MOVE:
System.out.println("Touch wurde bewegt @");
break;
case TOUCH_CANCEL:
System.out.println("Touch wurde abgebrochen @");
break;
}
touchPrinter.accept(touches);
});
// Das Listening kann wie folgt wieder aufgehoben werden
listenerRegistration.remove();