Skip to content

Commit

Permalink
InputHandler: fix zoom with numpad in latest libGDX, #972
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Nov 30, 2022
1 parent 7032428 commit 4e16a82
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions vtm-gdx/src/org/oscim/gdx/InputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

public class InputHandler implements InputProcessor {

private ViewController mViewport;
private final ViewController mViewport;
private final Map mMap;
private GenericLayer mGridLayer;
private final GdxMap mGdxApp;
Expand Down Expand Up @@ -102,19 +102,15 @@ public boolean keyDown(int keycode) {
mMap.updateMap(true);
break;
case Input.Keys.S:
mMap.animator().animateZoom(500, 0.5, 0, 0);
mMap.updateMap(false);
break;
case Input.Keys.W:
mMap.animator().animateZoom(500, 2, 0, 0);
mMap.updateMap(false);
break;
case Input.Keys.MINUS:
case Input.Keys.NUMPAD_SUBTRACT:
mMap.animator().animateZoom(500, 0.5, 0, 0);
mMap.updateMap(true);
break;
case Input.Keys.W:
case Input.Keys.PLUS:
case Input.Keys.EQUALS:
case Input.Keys.NUMPAD_ADD:
mMap.animator().animateZoom(500, 2, 0, 0);
mMap.updateMap(true);
break;
Expand Down Expand Up @@ -256,8 +252,8 @@ public boolean mouseMoved(int screenX, int screenY) {

@Override
public boolean scrolled(float amountX, float amountY) {
float fx = mPosX - mMap.getWidth() / 2;
float fy = mPosY - mMap.getHeight() / 2;
float fx = mPosX - (mMap.getWidth() >> 1);
float fy = mPosY - (mMap.getHeight() >> 1);
mMap.animator().animateZoom(250, amountY > 0 ? 0.75f : 1.333f, fx, fy, Easing.Type.LINEAR);
mMap.updateMap(false);
return true;
Expand Down

0 comments on commit 4e16a82

Please sign in to comment.