1

I created a map in tiled, here's what it is supposed tolook like:

enter image description here

However, when I render it, I don't get any of the graphics, I only my background colour and black bars, where my objects are supposed to be:

enter image description here

I don't understand what the problem is, here's my code in the screen it's being rendered:

public class GameScreen implements Screen {
    private OrthographicCamera cam;
    private MyGdxGame myGame;
    private Vector3 pos;
    private Viewport gameport;
    private TmxMapLoader mapLoader;
    private TiledMap map;
    private OrthogonalTiledMapRenderer mapRenderer;

    public GameScreen(MyGdxGame game){
        this.myGame = game;
        pos = new Vector3(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, 0);

        cam = new OrthographicCamera();
        cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        gameport = new ExtendViewport(1060, 2060, cam);
        mapLoader = new TmxMapLoader();
        map = mapLoader.load("game_map1.tmx");
        mapRenderer = new OrthogonalTiledMapRenderer(map);

    }
    @Override
    public void show() {
    }

    public void update(float delta){
        handleInput(delta);
        cam.update();

    }

    private void handleInput(float delta) {
        if(Gdx.input.isTouched()){
            pos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
//            cam.unproject(pos);
            cam.position.x = Gdx.input.getX();
            cam.position.y = Gdx.input.getY();
        }
    }

    @Override
    public void render(float delta) {

        update(delta);

        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        mapRenderer.setView(cam);
        mapRenderer.render();

//        myGame.sr.begin(ShapeRenderer.ShapeType.Filled);
//        myGame.sr.setColor(Color.BLUE);
//        myGame.sr.circle(pos.x, pos.y, 50);
//        myGame.sr.end();
    }

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void pause() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void hide() {

    }

    @Override
    public void dispose() {
    }
}

Someone care to explain what the problem is?

AEM
  • 1,354
  • 8
  • 20
  • 30
Dani007
  • 141
  • 1
  • 8

1 Answers1

0

So after a full day of trying different stuff, I finally figured it out:

I was using multiple images, or 'tile sets' to create the map. What I ended up doing was packing the parts I needed into a single .png using TexturePacker and using only that png/tile set to create my map.

Dani007
  • 141
  • 1
  • 8