0
\$\begingroup\$

I always thought that pixels were square... it turns out i'm wrong, and I am quite worried by this.
This means that if I draw a circle, it will be round on my screen but it could be an ellipse on someone else's.

My first question is: How common is that? Should I bother to take this in consideration when I draw my graphics/ scale my bitmaps? Or are such weird pixel shapes only used in not-intended-for-gaming screens like hi-tech washing machines?

And my second question is: How can i programmatically get the exact screen size in millimeters (both width and height) of my custom SurfaceView?

\$\endgroup\$
1
\$\begingroup\$

No. Pixels are squared. At least from an API point of view, you can safely assume that your pixels are square, and that if you draw a circle, you will get a circle.

What you're most likely experiencing is a problem where your target canvas size is not the same as the screen resolution, so pixels will seem stretched. What you need to do is figure out the resolution of the device, and then act accordingly. However...

Making a game that works on any aspect ratio is difficult. Generally, you have two choices: you either modify the game so it works on the target resolution (involves using coordinates and sizes relative to the screen corners, not absolute coordinates), or force the game to use whatever resolution (or aspect ratio) you wish, and then add black bars to compensate for the extra space.

I rarely see a game that does work on any aspect ratio, and black bars are much more common than I would like, but that's life.

\$\endgroup\$
0
\$\begingroup\$

You should let the user choose the resolution in the graphics options, or at least the ratio (16:9, 4:3). Obviously if the resolution is right for the screen, there shouldn't be any pixel stretching.

\$\endgroup\$
  • \$\begingroup\$ We are talking abut an Android game... I've never seen any doing this. \$\endgroup\$ – Riccardo Vailati Jan 14 '15 at 9:31
0
\$\begingroup\$

First question: You need to have multiple images to suit the user's screen size.

Second question: To get the user's screen size you would need to call the onSizeChanged() method which automatically captures the values of the screen, which you can then use to scale your images to fit the screen.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.