How to implement a slider when you drag your finger across the screen?

everywhere in the examples for scrolling a keyboard is involved:

OrthographicCamera camera; ... public void render () { if (Gdx.input.isKeyPressed(Input.Keys.LEFT)){ camera.position.x -= 5; ... 

and how to realize the movement of the camera when you hold your finger across the screen?

Thank.

  • Use GestureListener - Master Flomaster

1 answer 1

You need to write a class, implement GestureListener, implement the pan method. Then you need to create a GestureDetector, transfer it to your GestureListener and set it as an InputProcessor to the constructor. Here you can see https://github.com/libgdx/libgdx/wiki/Gesture-detection In addition, the touch pan coordinates come in screen coordinates, you can convert the unproject camera into game coordinates.