How to zoom/scale on android while keeping same pixels?

Just starting out? Need help? Post your questions and find answers here.
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

How to zoom/scale on android while keeping same pixels?

Post by T4r4ntul4 »

Hey all,

I have a openscreen(1200, 700) command with for example 1200 by 700 pixels, for a 2D game. It needs to be an Android app.
Problem is that there are way too many screen sizes.

What is the proper way to scale or zoom on those devices while keeping the same width and height in pixels?

Any thoughts or help is very appreciated!
User avatar
Danilo
Posts: 51
Joined: Wed Feb 26, 2014 7:11 am

Re: How to zoom/scale on android while keeping same pixels?

Post by Danilo »

You could use something like a "virtual resolution" and split it into tiles.
Your screen is 1200x700 and you divide it using 50x50 tiles into 24x14 blocks.
Each tile is 50 x 50 pixels. You have 24 tiles at the x-coordinate and 14 tiles at the y-coord.

24 x 14 = 336 blocks. If you open a screen with another resolution, you could divide the
screen height by 14. Whatever the screen resolution is, you always want to display
14 blocks at the y-coordinate (game field height). With the width of the screen, you could
do different. On a wide-screen (16:9) you display more tiles horizontally, on a smaller screen (4:3)
you display less blocks at the x-coordinate.
If you want to display always 24x14 blocks, it would look stretched or squeezed at some
displays.

Or you draw to an off-screen image (1200x700 or 800x600) and display this image scaled to the real screen size.
Stretched or with borders on the sides, etc. - however you want. ;)

- How do I make a 2D game resolution independent?
- Resolution Independent Rendering
- Solving Resolution Independent Rendering And 2D Camera
cya,
...Danilo
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: How to zoom/scale on android while keeping same pixels?

Post by T4r4ntul4 »

Hi thank you for your answer.

But thats not really what iam looking for.

If i have 1200x700 pixels for my openscreen() and my mobile screen is for example 600x800 pixels, i want to zoom out, so i can see all the same 1200x700 pixels on a 600x800 screen size.

Its like doing 'CTRL+-' several times in the browser.

Thing is, if iam displaying on the tablet something on lets say 1100x680 coords, it needs to be on the exact location on the phone screen. I do not want to recalculate every movement between 2 screen sizes. (its gonna be a game with a server in between)

So to make it easy for myself, i just want to zoom out on the phone (its a browser after all).

What is the easy way to do that?
Post Reply