Libgdx FitViewport shows black screen - Android -


i'm having problems libgdx viewport system on android. want set fitviewport on camera, , black screen. tried camera, without viewport , working. can't manage right on viewport.

here's code:

variables declaration:

private texture texture; private sprite sprite; private orthographiccamera camera; private float virtualwidth, virtualheight; private float aspectratio; private spritebatch batch; private viewport viewport; 

initialization

virtualwidth = 200; virtualheight = 200; aspectratio = gdx.graphics.getheight() / gdx.graphics.getwidth(); texture = new texture(gdx.files.internal("mapa.jpg")); sprite = new sprite(texture); camera = new orthographiccamera(); viewport = new stretchviewport(virtualwidth * aspectratio, virtualheight, camera); viewport.apply(); camera.position.set(virtualwidth / 2, virtualheight / 2, 0); batch = new spritebatch(); 

my render method:

gdx.gl.glclearcolor(1, 0, 0, 1); gdx.gl.glclear(gl20.gl_color_buffer_bit); camera.update(); batch.setprojectionmatrix(camera.combined); batch.begin(); sprite.draw(batch); batch.end(); 

and finally, resize method:

viewport.update(width, height); 

plz can point out wrong code?


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -