Java tutorial
/******************************************************************************* * Copyright (c) HALive, 2015. * For Licence information see LICENSE.md ******************************************************************************/ package halive.shootinoutside.util.ui; import com.badlogic.gdx.InputProcessor; import java.util.ArrayList; import java.util.List; public class MultipleInputAdapter implements InputProcessor { protected List<InputProcessor> processors = new ArrayList<>(); public void addProcessor(InputProcessor p) { processors.add(p); } @Override public boolean keyDown(int keycode) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).keyDown(keycode); if (done) break; } return done; } @Override public boolean keyUp(int keycode) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).keyUp(keycode); if (done) break; } return done; } @Override public boolean keyTyped(char character) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).keyTyped(character); if (done) break; } return done; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).touchDown(screenX, screenY, pointer, button); if (done) break; } return done; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).touchUp(screenX, screenY, pointer, button); if (done) break; } return done; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).touchDragged(screenX, screenY, pointer); if (done) break; } return done; } @Override public boolean mouseMoved(int screenX, int screenY) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).mouseMoved(screenX, screenY); if (done) break; } return done; } @Override public boolean scrolled(int amount) { boolean done = false; for (int i = 0; i < processors.size(); i++) { done = processors.get(i).scrolled(amount); if (done) break; } return done; } }