public class MyInputProcessor implements InputProcessor { @Override public boolean keyDown (int keycode) { return false; } @Override public boolean keyUp (int keycode) { return false; } @Override public boolean keyTyped (char character) { return false; } @Override public boolean touchDown (int x, int y, int pointer, int button) { return false; } @Override public boolean touchUp (int x, int y, int pointer, int button) { return false; } @Override public boolean touchDragged (int x, int y, int pointer) { return false; } @Override public boolean touchMoved (int x, int y) { return false; } @Override public boolean scrolled (int amount) { return false; } }
- keyDown(), keyUp(), keyTyped() : zdarzenia klawiatury
- touchDown(), touchUp(), touchDragged(), touchMoved(), scrolled() : zdarzenia dotyku/myszy
Po zaimplementowaniu metod klasy InputProcessor należy 'zarejestrować' procesor w LibGdx:
MyInputProcessor inputProcessor = new MyInputProcessor(); Gdx.input.setInputProcessor(inputProcessor);
Od tego momentu wszystkie zdarzenia wejściowe będą przekazywane do instancji MyInputProcessor. Obsługa zdarzeń następuje tuż przed wywołaniem ApplicationListener.render().
Brak komentarzy:
Prześlij komentarz