Android game on different screensize
in
Android Processing
•
3 months ago
Hi.
I am trying to build a simple android game with processing, but i have run into a problem with the different screen size on android phones / tablets.
To make things simple, let's say that it is a simple platform game, and i would like to put some "robots" on the screen, at specific positions, and they have a specific width and height.
I have used my mad photoshop skills to illustrate what i wan't to do
Now this is the problem. When i do not know the screensize, how shall i choose
position a and
b, so it will look the same on all screens. I have the same problem with
Width and
Height. They should also be calculated to the actual size og my device, so they don't apear bigger compared to the rest of the world on a device with a smaller screen.
Now what is the "best" way to archieve this
This is the thoughts i have had so far.
1) The easiest way i could think of, would be to hardcode the size to
800,480 and then i would know exactly where everything is.
But is there then any way, to stretch the entire sketch to the screens actual size afterwards? And will the x/y coordinates i get from input then match my original 800,480 sketch, or will they now match the resized image? If that is the case this technique can not be used.
But then i guess i have to position everything according to this. The only way i can see i can position things according to this would be something like:
Position a = displayWidth/60, displayHeight/70
And also i should set the width and height of the robot like
robotWidth = displayWidth/70;
robotHeight = displayHeight/75;
This should work, but it does seem like a lot of work to actually do this everytime i need to position something.
So what to do?
Which of the above solutions should i choose, or is there another better solution for this?
1