I'm using libgdx to render a map that is 32x32 tiles (with each tile being 32x32 pixels). I'm using the OrthogonalTiledMapRenderer for this. Then, I'm rendering a simple texture onto the screen that can move around using up/down/right/left. What I want is to get the position of the texture in terms of the map tiles positions. For example, if the texture is on top of tile (0, 0) I want to know this. So far, I've tried using camera.unproject(texcoordpositionVector) to get these, but it hasn't been working consistently.
Edit: here's how the map renderer and camera are setup:
SCALE = 10;
w = Gdx.graphics.getWidth();
h = Gdx.graphics.getHeight();
map = new TmxMapLoader().load("map.tmx");
camera = new OrthographicCamera(SCALE * (w / h), SCALE);
renderer = new OrthogonalTiledMapRenderer(map, 1/32f);
Then, to render:
camera.update();
camera.apply(Gdx.graphics.getGL10());
renderer.setView(camera);
renderer.render();
camera.unprojectis the right place to start, but you may need to massage the result based on your unit scale. - P.T.