Question

I am currently using TiledMap, SimpleTiledAtlas(still can't figure out how to use pack files) and TileMapRenderer, following this tutorial: http://code.google.com/p/libgdx-users/wiki/Tiles.

I don't know how to access the xyz of the map or how to change it in general. For initialization:

map = TiledLoader.createMap(Gdx.files.internal("tiles/tiles.tmx"));
    atlas = new SimpleTileAtlas(map, Gdx.files.internal("tiles/"));
    tileMapRenderer = new TileMapRenderer(map, atlas, 128, 128, 8, 8);

And for my rendering:

camera.zoom = 1.0f;
    camera.update();
    tileMapRenderer.render(camera);
    batch.begin();
    font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 20, 20);
    tmp.set(0, 0, 0);
    camera.unproject(tmp);
    batch.end();

I've tried changing the tmp xyz but it doesn't seem to work. Also TileMapRenderer and TiledMap don't seem to have x and y fields. Am I missing something or just too tired to notice?

Was it helpful?

Solution

You move the camera, as opposed to the TiledMap or TileMapRenderer.

The TiledMapTest shows an example of how this works.


EDIT

The tile map api in LibGDX has changed since this answer was posted.

See TiledMapDirectLoaderTest for an equivalent test using the new api.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top