How to use the zoom gesture in libgdx?
- by user3452725
I found the example code for the GestureListener class, but I don't understand the zoom method:
private float initialScale = 1;
public boolean zoom (float originalDistance, float currentDistance) {
float ratio = originalDistance / currentDistance; //I get this
camera.zoom = initialScale * ratio; //This doesn't make sense to me because it seems like every time you pinch to zoom, it resets to the original zoom which is 1. So basically it wouldn't 'save' the zoom right?
System.out.println(camera.zoom); //Prints the camera zoom
return false;
}
Am I not interpreting this right?