v0.7.5e: added scroll wheel support

This commit is contained in:
Evan Debenham
2019-10-22 20:08:49 -04:00
parent 2ca6815050
commit 53907d8b7a
6 changed files with 214 additions and 38 deletions

View File

@@ -23,12 +23,14 @@ package com.watabou.input;
import com.badlogic.gdx.InputAdapter;
import com.watabou.noosa.Game;
import com.watabou.utils.PointF;
public class InputHandler extends InputAdapter {
public void processAllEvents(){
PointerEvent.processPointerEvents();
KeyEvent.processKeyEvents();
ScrollEvent.processScrollEvents();
}
// *********************
@@ -59,6 +61,18 @@ public class InputHandler extends InputAdapter {
return true;
}
//TODO tracking this should probably be in PointerEvent
private static PointF pointerHoverPos = new PointF();
@Override
public boolean mouseMoved(int screenX, int screenY) {
screenX /= (Game.dispWidth / (float)Game.width);
screenY /= (Game.dispHeight / (float)Game.height);
pointerHoverPos.x = screenX;
pointerHoverPos.y = screenY;
return true;
}
// *****************
// *** Key Input ***
// *****************
@@ -85,4 +99,13 @@ public class InputHandler extends InputAdapter {
return true;
}
// ********************
// *** Scroll Input ***
// ********************
@Override
public boolean scrolled(int amount) {
ScrollEvent.addScrollEvent( new ScrollEvent(pointerHoverPos, amount));
return true;
}
}