Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
September 30, 2014
arrowPress Releases
September 30, 2014
PR Newswire
View All





If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 
Dealing with Android resolutions
by Prafful Sahu on 08/14/14 02:23:00 am

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 
Considering the android resolutions are so fragmented, I partly worked on a solution for dealing with it (This solution particularly works best for 2dToolkit, though I think the principle can be applied to others also). So rather than catering for resolution it is best to deal with the aspect ratios. So I listed down the possible aspect ratios along with some exceptions. Here is my list:
  1. 3:2
  2. 4:3
  3. 5:3
  4. 16:9
  5. 16:10
  6. 80:47
  7. 128:69
  8. 128:75
  9. 427:240
The last four of the ratios are for certain devices which are quite popular in most of the developing countries.
My code now determines first that to which particular ratio a device belongs using the following snippet.
 
     bool AspectRatioIs(int width,int height)
     {          
          if(Mathf.Abs((width - Camera.main.aspect*height)/height) <= 0.02f)
               return true;
          return false;
     }
 
The above code determines to which particular aspect ratio we are dealing with. Now in your entry function you can simply write cases for each of the aspect ratio, for eg: I wrote in my Start() code for adjusting a particular button to a needed position.

Related Jobs

Jintronix
Jintronix — Montreal, Quebec, Canada
[09.30.14]

Game Developer at fast-growing healthcare technology startup
InnoGames GmbH
InnoGames GmbH — Hamburg, Germany
[09.30.14]

Mobile Developer C++ (m/f)
Raven Software / Activision
Raven Software / Activision — Madison, Wisconsin, United States
[09.30.14]

Sr. Gameplay Engineer - Raven
Raven Software / Activision
Raven Software / Activision — Madison, Wisconsin, United States
[09.30.14]

Lead Engineer - Raven






Comments


Javier Degirolmo
profile image
Usually it's better to not hardcode for any ratio at all and assume the resolution can be just about anything (usually this means positioning everything relative to the borders and center of the screen). Then you don't have to worry much about what resolution the player is using.


none
 
Comment: