Keith Myers
Keith Myers

Reputation: 1369

WP7 XNA game: how to adapt to different phone resolutions?

I've created a game that targets the 800 x 480 resolution, but have become interested in having it adapt to other WP7 resolutions. Also, I've heard that games can be ported to iPhone and Android through Mono and ExEn, opening up a ton of other screen resolutions.

What is the proper way to deal with this? I'd like to make the game smart enough to detect the screen size and alter the assets to look as close to the original as possible and play the same.

This is a 2D game and I would think the ideal would be to have separate images for all resolutions, but to be future-proof this wouldn't work. I've thought of having a baseline of 800 x 480, detecting size at start, and altering the Bounds of all my entities to scale, then simply draw the textures to those targets. This would allow me to do my collision detection correctly as well as scale the textures, but there is likely a better way.

Anyway, I hope I have explained the issue clearly. If not, I will edit the question after comments come in.

I appreciate your input.

Upvotes: 0

Views: 909

Answers (2)

Hermit Dave
Hermit Dave

Reputation: 3046

Currently WP only supports 800 x 480 resolution. In future when different resolutions are allowed, there has been talk of automatic scaling. So far nothing has come out and i'd suggest that you take it easy.

Edit: Thanks for the heads up.. re-read the post. yes Mono allows you to write for both Android and iOS and you can share lots of code http://xamarin.com/ for more info.

The idea is to have a common library (engine etc) and then optimise UI to suit different platforms.

Upvotes: -1

Ani
Ani

Reputation: 10896

For the benefit of people who land here when Windows Phone might support multiple resolutions (or looking for this answer to write true multi-resolution engines), this is how I do it.

I enumerate/check the available resolutions and set up orthographic projections for resolutions with aspect ratios that I know already. To this end, I hard-code a table of aspect ratios I have tested my game on and the "reference" widths/heights for each of these aspect ratios. I then look at the current requested resolution, find its aspect ratio and look through my table for the closest-lower matched aspect ratio and set up an ortho projection (centered - so if height matches but width doesn't or vice-versa, letter-boxing automatically happens) and viewport accordingly.

For example: I'd set up an ortho projection of 1280x720 for qHD (960x540), WXGA (1280x720) and FHD (1920x1080) because all three of them have the same aspect ratio.

On both SVGA and DVGA (960x640) display with aspect 1.5, I would set up SVGA 800x600 resolution so everything looks ok.

The above method makes sure that if you design your assets for the aspect ratios your main target devices use, they will not see any squashing. Note that this method is NOT for determining the actual resolution of your assets.

Upvotes: 3

Related Questions