I made a tilemap using Tiled, and I copy pasted both it and its tsx file into android assets, but for some reason the thing can't load the png files in my tsx file.
Here is the code I have to render the thing:
public class PlayScreen implements Screen {
private GenericGame game;
private OrthographicCamera gamecam;
private Viewport gamePort;
private Hud hud;
private TmxMapLoader mapLoader;
private TiledMap map;
private OrthoCachedTiledMapRenderer renderer;
public PlayScreen(GenericGame game){
this.game = game;
gamecam = new OrthographicCamera();
gamePort = new FitViewport(GenericGame.V_WIDTH, GenericGame.V_HEIGHT, gamecam);
hud = new Hud(game.batch);
mapLoader = new TmxMapLoader();
//Put The tiledmap in here vib.
map = mapLoader.load("Generic Map Box 2.tmx");
renderer = new OrthoCachedTiledMapRenderer(map);
gamecam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2,0 );
}
@Override
public void show() {
}
public void HandleInput(float dt){
if(Gdx.input.isTouched())
gamecam.position.x += 100 *dt;
}
public void update(float dt){
HandleInput(dt);
gamecam.update();
renderer.setView(gamecam);
}
@Override
public void render(float delta) {
update(delta);
// makes screen black
Gdx.gl.glClearColor(0,0,0,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.render();
game.batch.setProjectionMatrix(hud.stage.getCamera().combined);
hud.stage.draw();
}
@Override
public void resize(int width, int height) {
gamePort.update(width,height);
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void hide() {
}
@Override
public void dispose() {
}
}
It should have shown my tiledmap in the window, but it just cant load any of the tiles for the tileset.