How to deal with multiple aspect ratios - android

I'm developing a 2D puzzle like game. I want to target all iOS devices (iphone 4+ ,ipad 2+ and retinas) and as much android devices as possible. The problem is as you already guessed with resolutions and aspect ratios. How to deal with it, and what are the best practices. please share your experience and best approaches with this problem. My approach is , I'm building for 3:4 (the game is in portrait mode) aspect ratio with ipad retina resolution images and using orthographic camera. for different aspect ratios i resize orthographic camera , and as expected I get black bars at the top and bottom . aka pillarbox. so I'll just resize (scale Y) the main scene. (drop everything in an empty gameObject and scale it up). or add 2nd camera to deal with this black bars. But I need the best and the most correct way to deal with this problem , what's the best practices for 2D game development when targeting multiple resolutions,aspect ratios. I've searched the net and forum but couldn't find the CORRECT WAY.

Related

Converting iOS game dimensions for Unity2d android

I recently started working learning Unity2d from an iOS background. I am using the FWVGA Landscape (854x480) dimensions. I resized a 1136x640 background image (which I use for iOS) to 854x480 and made a sprite with the image but it only took a small portion of the screen. I had to resize the image in Unity. What are the general rules for converting dimensions from iOS to Android on Unity to get the dimensions to fit?
1136x640 is the ratio 16:9, as is 1920x1080 (1080p). Note a quick way to check the ratio: 16/9 = 1.77r. 1920/1080 = 1.77r. 1136/640=1.77r, 854/480 = 1.77r. All the same 16:9 ratio.
So, for Android phones that are also 16:9 you don't "need" to resize your assets unless say you want to up the resolution for quality sake on more powerful Android devices.
If you want to do it quick and easy then you want to draw your game in a camera at 1336x640 and then scale the camera view to match the resolution of the device you are running on (be it 1920x1080, 640x480, etc - all the same ratio).
You get problems with devices that are not 16:9 like tablets or phones that are say 16:10, 5:3, 3:2, or the iPads and Nexus 9 tablets at 4:3. This is a long subject though and there are lots of guides around to help. Try searching for "Unity 2d multiple screen ratios".
I think there are just too many variables to make this work "simply"
854x480 doesn't sound like a 'standard' HxW to me. and Unity is a 3D game engine which means its camera is on the Z axis when you are "looking down upon" a 2D game.
So the camera Z axis(Which apparently Unity tries to 'adjust' to match the phone's size, the phone's physical size, the size of the image you are using, etc. There are just a lot of variables. I would recommend https://stackoverflow.com/a/21375938 to see if that helps.

Unity 2D : How to support multi platform and different aspect ratio devices in Unity 2D?

I am newbie to Unity 2D and creating a game in it. I wanted to run that game on almost all devices (Android, iOS, Mac, Windows and web. I am bit curious to see how Unity2D will handle this scenario and give the same user experience on various devices.
Also I noticed that I can preview my game in different aspect ratios. Is it the aspect ratio of the screen (like how the game would look on this type of screen) or of the camera (would look the same on all screens)? Do I need to provide different image resources based on the device's resolution?
Should I do something special to allow support for different resolutions, aspect ratios, etc?
Any help will be appreciated.
Aspect ratio management is explained in the following blog post: http://2sa-studio.blogspot.com/2015/01/handling-aspect-ratio-in-unity2d.html
Basically the orthographic camera has a size parameter which defines the half-height of the world area which will be rendered on screen.
Unity strategy is: fit rendered area height to screen height. Then the visible width varies depending on the screen ratio.

Android game location on screen size

Right now my game is using direct x and y values. I realized that my the S3 was scaling my images double size along with some other size inconsistencies between devices. I read around and learned a bit about android dpi and scaling and stuff.
I'm wondering whats the correct way to do locations and stuff so that it takes into account different screen sizes.
I'm thinking it can be done by setting a target dimension and then scaling all positional values according to the ratio of the target dimension to the actual screen size.
I also read somewhere that you can draw onto a buffer and display that buffer stretched to the screensize, however for this method would android's auto resizing affect the drawn bitmaps?
Thanks
The idea is to use aspect ratio, android auto resizing to your benefit. Every android screen has its own aspect ratio, your game should use the aspect ratio and fill blackborder where ever there is a need to fill space on the screen. So use appropriate root layout fitting attributes.
Android resizes drawables automatically that dont fit. So if you keep only 1 set of drawables, the resizing work for Android increases and it uses Bitmap's internally to do the resize. More the bitmaps more the memory utilization, more the cleanup, more the GC and slower your game. So the best practice here is to create different dpi different image sets to use.
To start with I suggest that you purchase 3 phones, samsung y (small screen), samsung s2 (good screen) and a tab 7 or 10 inch. Copy your original drawables to all the folders, just to get a feel of the game and to eliminate all memory issues. Once your game works nicely, smoothly without any memory issues on all the phone sizes, just walk into a graphic designers office and show him how bad your game looks on some phones. He will create graphics that will work for that dpi.
Its a game of intelligent drawable resolution, sizing and A WHOLE LOAD OF TESTING :).
Hope this has helped.
Edit : Read my answer in memory issues

Better way for Andengine screen size?

I understand that Andengine gives us option to scale our scene to any size screen that the user may have.
My question is if it would be better to develop for a larger resolution, say 1280/800 and scale it down for smaller screens OR to go for smaller resolution, say 800/480 and scale it up on bigger screens?
I did try to test this in a sample game by developing it for 1280/800 and scaling down (by ratioResolutionPolicy) to 800/480, and the results weren't satisfactory, there was stutter every here and there the framerate on the debugger though showed 60+. Is it bad programming on my part or does it have to do with the scaling down of the pixels, should I develop for smaller screen and scale it up?
I guess it depends on what kind of graphics you are using.
Say, for example, you want to create something in a retro-gameboy-pixel style, then it makes more sense to use small images and develop for a small resolution (like 480x320). Pixel graphics can be scaled up without loosing quality, but not down (then the pixels loose form).
But if you want high resolution graphics you are most likely better of developing the whole thing for a big resolution and let the AndEngine scale it down.
In both cases the quality of the pictures also depends on the TextureOption of your TextureAtlases as well.
Anyway, I can imagine that neither scaling down, nor scaling up is more efficient. Scaling is done by openGL and should go quite quickly. The downside of using big resolutions though, is that the device has to hold huge images in it's memory and the of course processing big images always takes more time than processing small images. So maybe the best way is to develop for middle-size devices (e.g. 960x640) ?
I know this isn't much help, unfortunately it is a lot of try and error to get the best results for your specific requirements.
christoph
To achieve good result on all type of android device you have two ways to follow from my perspective.
First, you have to develop and use two graphics to handle all the type of devices. For example one with resolution 1024x600 and other with 480x320. Based on device current resolution you have to load specific one type of graphics.
Second, you choose any single resolution that best suits to you and have great share in the market. Develop and use graphics only for that resolution. For other resolution scale that graphics based on aspect ratio. For this you have to create super class of sprite and change value of x,y,height and with based on aspect ratio calculate.
This was my experience that I share with you. If you have any doubt then feel free to ask it.

aspect ratio for a game on different mobile device screens

i am making a game on different platforms, and i need to maintain a fixed aspect ratio while rescaling the game based on different device screen sizes...
1) so theres many different screen sizes because there are many different android, ios and blackberry devices. is there a suggested aspect ratio for all of them, a universal aspect ratio?
2) Otherwise, do each of these device have a different screen resolution (ie 540X480, 1024X720 etc)? Does that mean i have to target only a fixed number of mobile devices (ie 5), and mathematically find an aspect ratio for the screen resolution of each mobile device?
3) is there a more optimal way to do the above?
much appreciated!
When dealing with game screen sizes, you usually want to have an fixed screen ratio (depending on the type of game), not to give some people an advantage and others a disadvantage (due to users playing your game on different devices).
I develop on a 320x470 ratio (since this is the most common screen ratio for Android mobile devices). I suggest you develop your game based on this ratio.
When actually rendering the framebuffer, you either stretch it to fill the screen or you use a technique called letterboxing. Both have their pros and cons.
I hope this gave you a greater insight and maybe an idea how you are going to tackle your problem.

Categories

Resources