libGDX mouse wheel zoom with pivot, closes #169
This commit is contained in:
@@ -218,7 +218,6 @@ public class InputHandler implements InputProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseMoved(int screenX, int screenY) {
|
public boolean mouseMoved(int screenX, int screenY) {
|
||||||
|
|
||||||
mPosX = screenX;
|
mPosX = screenX;
|
||||||
mPosY = screenY;
|
mPosY = screenY;
|
||||||
return false;
|
return false;
|
||||||
@@ -226,18 +225,10 @@ public class InputHandler implements InputProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scrolled(int amount) {
|
public boolean scrolled(int amount) {
|
||||||
|
float fx = mPosX - mMap.getWidth() / 2;
|
||||||
if (amount > 0) {
|
float fy = mPosY - mMap.getHeight() / 2;
|
||||||
|
mMap.animator().animateZoom(250, amount > 0 ? 0.75f : 1.333f, fx, fy);
|
||||||
mMap.animator().animateZoom(250, 0.75f, 0, 0);
|
|
||||||
} else {
|
|
||||||
float fx = mPosX - mMap.getWidth() / 2;
|
|
||||||
float fy = mPosY - mMap.getHeight() / 2;
|
|
||||||
|
|
||||||
mMap.animator().animateZoom(250, 1.333f, fx, fy);
|
|
||||||
}
|
|
||||||
mMap.updateMap(false);
|
mMap.updateMap(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user