My game's main game class is a Screen which also implements InputProcessor to handle touch events.
The screen renders a TMX map using an HexagonalMapRenderer and a Camera, like this:
_camera = new OrthographicCamera();
_map = new TmxMapLoader().load("1087.tmx");
_mapRenderer = new HexagonalTiledMapRenderer(_map);
_camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
To allow the user to scroll the map, I am overriding the touchDown and touchDragged methods; it works.
However, I also have a Scene2D Stage rendering on the Screen, which I use to display some buttons.
They get displayed. and I have created a ClickListener like this:
button.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
System.out.println("Clicked!");
}
});
If I use
Gdx.input.setInputProcessor(this);
Only the Screen scrolling functions will work, and the buttons will become unresponsive.
On the other hand, if I use:
Gdx.input.setInputProcessor(stage);
I will be able to use UI buttons, but the map will become unresponsive.
I'd like to enable both (map will scroll if user clicks anywhere BUT the UI buttons, it will then fire the button clicked listener), is there any way to do this?
Thanks.