Libgdx Tiled Map Renderer doesn't draw anything

Viewed 48

I have problem with tiled map rendering. I don't know why OrthogonalMapRenderer doesn't work.

constructor :

    this.batch = new SpriteBatch();
    Gdx.graphics.setVSync(true);
    this.cam = new OrthographicCamera();
    this.viewport = new StretchViewport(Main.WIDTH / Main.PPM, Main.HEIGHT / Main.PPM, this.cam);
    this.shapeRenderer = new ShapeRenderer();
    this.world = new World(new Vector2(0 , 0) , true);
    this.b2Renderer = new Box2DDebugRenderer();
    this.wBuilder = new WorldBuilder(this.world , this.cam);
    Gdx.input.setInputProcessor(new InputMultiplexer());
    this.map = new TmxMapLoader().load("maps/chamber/chamber.tmx");
    this.mapRenderer = new OrthogonalTiledMapRenderer(this.map , 1 / Main.PPM);
    this.cam.position.set(this.viewport.getWorldWidth() / 2 , this.viewport.getWorldHeight() / 2 , 0);

update method :

this.cam.update();
this.world.step(1f / 60, 2, 5);
this.mapRenderer.setView(this.cam);

render :

this.update(delta);
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);


    this.mapRenderer.render();

    this.shapeRenderer.setProjectionMatrix(this.cam.combined);
    this.batch.setProjectionMatrix(this.cam.combined);
    this.shapeRenderer.begin(ShapeType.Filled);

    // draw some shapes

    this.shapeRenderer.end();

    this.batch.begin();

    this.drawB2();

    this.batch.end();

I checked it out and it should be good , Program sees map layers , and objects but can't render it. Also there are no errors all map files are correct i'm sure.

0 Answers
Related