java - LibGDX - Tiled not rendering entire map -
i'm trying draw map in libgdx. map created in tiled.
problem: click here see picture of map looks while rendered. , this picture trying render. tried making fresh tiled map 1 layer of grass , few flowers, when try render that, nothing appears @ all. how can fix render entire tiled map?
any appreciated!
code:
game class
private gamescreen screen; @override public void create () { setscreen(new gamescreen()); } @override public void render () { super.render(); screen.render(gdx.graphics.getdeltatime()); } @override public void dispose () { super.dispose(); screen.dispose(); } @override public void resize(int width, int height) { super.resize(width, height); screen.resize(width, height); } @override public void pause() { super.pause(); screen.pause(); } @override public void resume() { super.resume(); screen.resume(); } public void setscreen (gamescreen screen) { if (this.screen != null) this.screen.hide(); this.screen = screen; if (this.screen != null) { this.screen.show(); this.screen.resize(gdx.graphics.getwidth(), gdx.graphics.getheight()); } }
gamescreen class
private tmxmaploader maploader; private tiledmap map; private orthogonaltiledmaprenderer maprenderer; private orthographiccamera camera; private fitviewport viewport; public gamescreen() { camera = new orthographiccamera(gdx.graphics.getwidth(), gdx.graphics.getheight()); camera.settoortho(false); camera.update(); viewport = new fitviewport(gdx.graphics.getwidth(), gdx.graphics.getheight()); viewport.setscreenposition((int) (gdx.graphics.getwidth() * 0.5f), (int) (gdx.graphics.getheight() * 0.5f)); maploader = new tmxmaploader(); map = maploader.load("maps/town.tmx"); maprenderer = new orthogonaltiledmaprenderer(map); } @override public void show() { } public void input() { } public void update(float delta) { input(); camera.update(); maprenderer.setview(camera); } @override public void render(float delta) { update(delta); gdx.gl.glclearcolor(0, 0, 0, 1); gdx.gl.glclear(gl20.gl_color_buffer_bit); maprenderer.render(); } @override public void resize(int width, int height) { viewport.update(width, height); } @override public void pause() { } @override public void resume() { } @override public void hide() { } @override public void dispose() { map.dispose(); maprenderer.dispose(); }
i believe problem tileset png file. file 256x8100 or in resolution. changed more reasonable tileset , not have problem @ all. hope else comes across problem see potential fix. :)
Comments
Post a Comment