Hello,
Can someone tell me why my map is not rendering in the full camera view?
My code:
package Module;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.loaders.TileAtlasLoader;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.tiled.TileAtlas;
import com.badlogic.gdx.graphics.g2d.tiled.TileMapRenderer;
import com.badlogic.gdx.graphics.g2d.tiled.TiledLoader;
import com.badlogic.gdx.graphics.g2d.tiled.TiledMap;
import com.badlogic.gdx.math.Vector3;
/**
*
* @author Celes Eternal
*
*/
public class Map {
/*
* Data
*
*/
//Block size
static final int BLOCK_WIDTH = 32;
static final int BLOCK_HEIGHT = 32;
//class data
private TileMapRenderer tileMapRenderer;
private TiledMap map;
private TileAtlas atlas;
private OrthographicCamera cam;
public Map(){
// Load the tmx file into map
map = TiledLoader.createMap(Gdx.files.internal("data/testMap.tmx"));
// Load the tiles into atlas
atlas = new TileAtlas(map, Gdx.files.internal("data/"));
// Create the renderer
tileMapRenderer = new TileMapRenderer(map, atlas,32, 32, 5, 5);
//initialize
cam = new OrthographicCamera(Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
cam.position.set(0, 0, 0);
//cam.translate(Gdx.graphics.getWidth() / -2, Gdx.graphics.getHeight() / -2);
}
public void render() {
cam.zoom = 1f;
cam.update();
tileMapRenderer.getProjectionMatrix().set(cam.combined);
Vector3 tmp = new Vector3();
tmp.set(0, 0, 0);
cam.unproject(tmp);
tileMapRenderer.render( tmp.x, tmp.y,
Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
}
Thanks
ps : sorry for my english