Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Best way to handle different screen sizes?

Author
Message
theUsual
8
Years of Service
User Offline
Joined: 13th Jul 2015
Location: Norway
Posted: 16th Jul 2015 02:34
I'm happy to anounce that I made my first app! It's called 777 by CarDan Studio on Google Play Store as the app might be relevant to the question.
https://play.google.com/store/apps/details?id=com.cardan.a777

While I was working on the app, I made a menu system with several "screens" (play game is one "screen", credits is another)

At first I tried to use a fixed resolution for my app, which resulted in text that was placed at 0,0, ended up 200px down from the top, even though the SetClearColor (150, 150, 150) filles the whole screen.

I then changed the environment settings to this:


Later on, when placing sprites and text dynamically, I used this approach:


I'm calculating the size, x-position and y-position induvidually for every element. Here's the y-position code:


If you look at the "Stats" picture of my app, you can see how I've positioned every text element. This layout will always look the same on every device according to their screen size. Text and sprites will be smaller on smaller screens, but they will look identical to a bigger screen. It's basically a scaled down version.

Now, I'm sure there is a better way.
Let's say I want to make a keyboard layout with different sprites for each character on a standard keyboard. Then I would have to do all these calculations for every single sprite to ensure that they would always stay in their places respectively. And what if I wanted to move the sprites to different places on the screen now and then? The device would suffer major calculation sickness leading to a slow app.

What's the best way of getting around this?

-Daniel
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Jul 2015 10:40
If you don't set a virtual resolution, then the default is behaviour is the percentage system. top left is 0,0 and bottom right is 100,100. It will always fill the device dimensions.

Personally I never got my head around the approach of not knowing the final outcome, but lots of others use it and love it.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
theUsual
8
Years of Service
User Offline
Joined: 13th Jul 2015
Location: Norway
Posted: 16th Jul 2015 14:11
I'll take a look at the percentage system. Luckily, my friends have phones with different sizes, so it's easy to test how it will look at any time.

0-100 in position sounds very inaccurate if it's integers only. Is 4.53, 80.30 a valid position, or does it have to be an integer?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Jul 2015 16:36
You can use floats, everything is shifted to the nearest pixel. Again, I'm not the expert in using this system. But I do use fixed resolutions like 720x450 and combine it with float values for higher resolutions. All virtual resolutions are arbitrary scales that get converted to actual device resolutions.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 19th Jul 2015 03:01
You might want to reconsider the name '777'.

I did a search in Google Play (on my phone) and it did not show up.

And lots and lots of other apps did. It is a popular set of characters for slot machine games.

And yours appears not to be related to slot machines.

Instructions on what to do and how to 'win' might not hurt.

Cheers,
Ancient Lady
theUsual
8
Years of Service
User Offline
Joined: 13th Jul 2015
Location: Norway
Posted: 19th Jul 2015 03:45
I'm using the percentage system in my new app, and I liked it very much!
If I'm importing a perfect square sprite(i.e. 32x32), I use this code:


And I'm using this code when loading a rectangular image:

Works very good, and I liked the approach much better.


Quote: "You might want to reconsider the name '777'."

Thank you. I'm always happy for feedback.
I feel it would interrupt the apps whole meaning if I changed the name. Then I would not only have to change the title, but also the game.
'777' was selected because of these reasons:
1) 7 is a "magical" number.
2) 555 was to "common". 888 was to high. 700 was to boring. 777 was better because you can't keep track of the time as easy as it would be just looking at the hundredth number; 1xx -> 2xx -> 3xx -> 4xx, etc.
3) Also named it 777 cause it is related to slot machines, hoping that it some day would reach the top and grab a extra downloads from people who was looking for slot machines stumbled across my app. (lol)

Also, the app is there when you search for it, you just have to scroll for a while... But as a first project, I don't care that much. A new app is on the way, and I already have like 5-6 more ideas.

Login to post a reply

Server time is: 2024-04-23 18:05:23
Your offset time is: 2024-04-23 18:05:23