[Solved] So many ways to deal with different android DPI/Resolutions.... Which?

Hi forum!
Recently i published my 2nd game in googleplay and i made a terrible mistake!

I programmed with the resolution of 800x600 in mind.
So The windows size starts at 800x600.

Later i use the code in annex to render the main menu.

It seems that, people with a small cellphone but with a high resolution will see the buttons very small.

So i went to libdgx chat researched, then went to google and found thousands of ‘solutions’ for me to test what suit me better. But which one of them is the correct one?
How do you guys do it? I decided to make a topic because i know you guys will able to tell me what direction should i go!

This is the game i published :

It uses box2d , idk if does matter because of “pixels per meter” stuff.

By the way, i did try using Fitviewport and it causes black bars.

http://www.java-gaming.org/index.php?topic=25685.0


http://pastebin.com/baQkGJ67

The question of “which is right for me” can only be answered by you. Different developers are going to have different approaches, and you should really do whatever makes the most sense to you.

What resolutions are you targeting? If your answer is “all of them”, what are some of the biggest and smallest?

I personally just target 1280x800 and just scale down. But you should do whatever makes the most sense to you.

You target “1280x800” but what about full HD screens?

Thats really confusing.

I wanted to target all of them. Or at least the most common ones.

There are 2 things you need to consider when making a game for mobile devices. Texture sizes and UI scale.

The bigger the scale you set, the higher quality assets you will need for the UI to look good.

The scale of the UI depends on the game you have. If your UI assets require pixel perfect scaling, (1, 2, 4, 8, 16, etc), then you will need to probably hard code scale for every device size/density there are.
http://developer.android.com/guide/practices/screens_support.html
https://developer.android.com/about/dashboards/index.html
For example, if your game is targeted for 480x320, the xlarge / xhighdpi device would mean that the scale will probably be 4x (480x4 = 1920 which is full HD device).
If you UI doesn’t require pixel perfect scaling, (I think this is your case), then you can just calculate the scale like this and see how it looks. You might want to “clamp” the value if it looks crappy on some devices so that scale is only certain values (1.0, 1.5, 2.0 2.5, 3.0, 3.5)


scale = screen.width / 800;
// if screen.width is 1280, then scale will be 1.6
if (scale < 1.5)
     scale = 1.0;
else if (scale < 2.0)
     scale = 1.5;
else if (scale < 2.5)
     scale = 2.0;

This should get you started I guess.

Thanks trollwarrior this solved the problem.