java - libgdx using percentage for images -



java - libgdx using percentage for images -

i'm making game sort of flappy bird, works on landscape mode, create fair people bigger screens don't have advantage alter images screen % illustration bird 10% of screen height, same in screens, question is, thought or there other way?

you don't need utilize percentages. if using libgdx, can (and should) utilize predefined viewport size, screen resolution handled library , not you.

you can accomplish using camera, setting fixed height, , calculating width:

height = 10; width = (gdx.graphics.getwidth()/gdx.graphics.getheight())*height; photographic camera = new orthographiccamera(); camera.settoortho(false, width, height);

this way, height 10 units. , width caculated screen x-y ratio.

the bird 10% of screen height

then bird 1 unit size (height/10).

if want both sides fixed (so noone sees more in width). easier, images won't maintain ratio, stretched in both axis.

height = 10; width = 15; photographic camera = new orthographiccamera(); camera.settoortho(false, width, height);

java libgdx screen-resolution screen-size

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -