Resolution independent positioning

Started by
11 comments, last by futlib 13 years, 2 months ago
[font=arial, verdana, tahoma, sans-serif][size=2]

perhaps you should try
smartly using matrices
transforming nicely


You lost me there, would you mind elaborating on this?[/font]

Another general purpose "surprisingly easy" approach is to just add black bars as needed, and render at your own preferred size.

This works nicely even on windowed environments, not just full screen. If the display window is too wide, draw it as maximum height and put black bars on the sides. If it is too tall, draw at maximum width with bars above and below. Keep your game in a floating point 0.0 to 1.0 size so you'll still be able to access each individual pixel for any size screen currently imaginable.


That sounds reasonable, but I'm a bit worried that if we use the "minimal screen area" (that one which will be visible on all resolutions) and add black bars on all larger screens, we will effectively see black bars on almost every device. Guess it's okay though, the user will probably not notice and it doesn't really matter whether I use black bars or more of the background image, the space can't be used for gameplay anyway. Technically, the solutions are very similar, I just have to center the background vertically.

The 0.0-1.0 based positioning idea sounds really good to me, guess I'll do that. Less confusing than to work with a reference solution. But I will also see if Android's density independent pixels do the trick for me, because I won't be able to use the former in layouts.
Advertisement

[font="arial, verdana, tahoma, sans-serif"][quote name='way2lazy2care' timestamp='1297712600' post='4774219']
perhaps you should try
smartly using matrices
transforming nicely


You lost me there, would you mind elaborating on this?[/font][/quote]

probably because I answered in haiku. You should be able to draw to a standard size, then use a transformation matrix to alter it as needed to fit all resolutions.

android should handle a lot of the resolution independence for you though.

http://developer.android.com/guide/practices/screens_support.html

[quote name='futlib' timestamp='1297782058' post='4774485']
[font="arial, verdana, tahoma, sans-serif"][quote name='way2lazy2care' timestamp='1297712600' post='4774219']
perhaps you should try
smartly using matrices
transforming nicely


You lost me there, would you mind elaborating on this?[/font][/quote]

probably because I answered in haiku. You should be able to draw to a standard size, then use a transformation matrix to alter it as needed to fit all resolutions.

android should handle a lot of the resolution independence for you though.

http://developer.and...ns_support.html
[/quote]


Ah, I see. Well, although it's the title of this post, "resolution independence" is not really the problematic part of what I'm trying to do. Android's density independent pixels are everything I need for that. My problems lie with aspect ratio independence, but I think the two approaches that emerged in this thread are fine:
  • Just center the visible area and have small black areas above and below.
  • Make a background image that's large enough to fill every devices screen and center it for smaller devices, making sure that everything of importance can be seen on all devices.

I think I'll actually do both of this. The second approach for my current project and the first approach for the next one.

This topic is closed to new replies.

Advertisement