Pergunta

I am new to libgdx and i was wondering if someone could help me with sprite size. my screen is set to be 1280 x 720. for my desktop it looks great and the right size that i need it to be. but when i test it on my android, the sprite is way to small. How do you make screen size consistent?

to animate my sprite, i followed this. https://code.google.com/p/libgdx/wiki/SpriteAnimation

If anyone could help, that would be awesome. thanks in advance

Foi útil?

Solução

If your app is not going to have zoom feature (which is mostly the case), you should not decide sprite sizes in terms of pixels.

Since you are going to tackle so many screen sizes and resolutions, I'd suggest a way to handle sizing of sprites in a screen size and pixel density independent way.

  • Assume some resolution (probably largest that you'd like to provide support for) with a suitable aspect ratio.
  • Size and place your sprites properly in that stage as you like.
  • While drawing, scale it to the actual screen resolution. (Keep in mind what to do if the aspect ratio is less or more than you had intended).

This way, you are essentially setting sizes of sprites in terms of fraction of screen size which is really convenient to understand and your sprites will look same relative sizes on all resolutions.

Hope this helps.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top