I have created a hexagonal isometric tiled map using the HexagonalTiledMapRenderer in libGDX and the programme Tiled. The map is being rendered correctly, but I do not know how to access information about individual tiles, and therefore I do not know how to deal with user input.
What I want is to make a tile light up upon hovering over it (also that something about the tile can be printed, like what tile it is, i.e. forest, river, mountains), so I figure I'll need some sort of grid-like system, and I thought that would be given to me by the tiled map, but I cannot find it/understand it.
Some code
Main core class
public class MyGdxGame extends Game {
@Override
public void create () {
setScreen(new Play());
}
}
play class
public class Play implements Screen {
private TiledMap map, hexMap;
private HexagonalTiledMapRenderer hexRenderer;
private OrthographicCamera camera;
@Override
public void show() {
hexMap = new TmxMapLoader().load("hexTiledMap.tmx");
System.out.println(hexMap.getProperties().getKeys());
hexRenderer = new HexagonalTiledMapRenderer(hexMap);
camera = new OrthographicCamera();
camera.setToOrtho(false);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
hexRenderer.setView(camera);
hexRenderer.render();
}
@Override
public void resize(int width, int height) {
camera.viewportWidth = width;
camera.viewportHeight = height;
camera.update();
}
}
Example of what I want to do with it
I want to be able to, for example, make just one tile brighter, or more red, or make it disappear. So I basically want to make the tiles interactive. I want the programme to know, for example, what tile is under the cursor. These are all only examples, I hope you understand what I want.