I am new to Android game development. I want to develop an Android game engine.
But I am very confused now that how to handle multiple screen sizes. I tried following.
1) I used single drawable folder and used Bitmap.createScaledBitmap(...) method to rescale the background image. But for larger resolutions the image is blurring.
2) I used drawable-ldpi, drawable-mdpi, drawable-hdpi folders. Kept resources as stated below.
ldpi 120dpi 240x320 images
mdpi 160dpi 320x480 images
hdpi 240dpi 480x800 images
in this it scaled the background images and blurring effect is also very low.
but dont know how to scale images like logo proportionately for different
I want to create game engine which will automatically rescale images as in "Angry birds" game.
Please help me out which method is most correct one ???
Or if this approaches are wrong then what approach i should follow ... ???
Thanks in advance..
There are three approaches I normally see.
1) Fixed scale pipeline.
You code your entire game to work on a single screen size. Then you scale the entire game view to the real screen size.
If you are doing software rendering, you work in an off screen buffer and blit the result onto the real screen.
If you are working with OpenGL et. al. then you create a scaling matrix in your projection.
2) Variable scale pipeline.
You calculate scaled values for all coordinates and draw into the on screen buffer with scaled blits.
Often you have to store multiple copies of the graphics designed for different screen resolutions.
3) Variable screen architecture
You use layouts to control the placement of the game elements, the layouts change the position of the elements on
screen based on the available pixels
Java uses this a lot.
Graphics tend to be unscaled.
All approaches have their high and low points. I tend to look at the game design and decide if I can tweak the design to be resolution independent, if not then I have to pick one and run with it.
For example, a chess board. A chess board has to be 8 by 8. You cannot say my screen is X wide so I'm going to make the chess board 10 by 10.
In the angry birds type game though you can say "I need a minimum of X pixels on the screen, if the screen is smaller I have to scale the view, if it is bigger I can display more of the world"
Scaling artifacts are just a fact of life when you start doing resolution independent code, the only way I have found to avoid them is to procedurally generate content for the current screen resolution.