playMaker

Author Topic: Need help on aspect ratio handling  (Read 4414 times)

Slater

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Need help on aspect ratio handling
« on: October 29, 2013, 04:44:35 PM »
Hi,

So I have our app out for iOS and all there works great. I build a simple aspect ratio screen manager that checks the aspect ratio of the device and then it sets the camera (2d, orthographic) to the screensize that is the correct one for that ratio. It also moves the objects I have in the scene that acts as gui. Some basic arrows.

We recently released the app also for Android a few weeks ago and I thought I had covered even the most stupid aspect ratios for that. But now we got a support mail from one of our customers not being able to play the game since if the aspect manager doesn't set the apect ratio nothing works with zooming etc in the app.

Please look at the screenshots of how I have handled the aspect ratios and please guide me to how I should handle/fix this.

The last screenshot is not taken from the first scene where I do the "get the screen size ratio", but from one of the other scenes where placements for arrows(gui) is needed.

Thanks/
Slater

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14485
  • Official Playmaker Support
    • View Profile
Re: Need help on aspect ratio handling
« Reply #1 on: October 29, 2013, 11:11:01 PM »
Hi,

 Well, is this problematic ratio features in this fsm ( which one is it) ? I am not too sure what I should look at in your screenshot.

To test for a ratio, you can set the game view size, and test, have you tried that?

bye,

 Jean

Slater

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: Need help on aspect ratio handling
« Reply #2 on: October 30, 2013, 04:12:04 AM »
Well the problem is that it is not easy to know all the different aspect ratios out there. The tablet the customer has is a Galaxy GT-P5110 and that has a 16:10 aspect ratio. I have covered that ratio in my manager but the problem with Android devices also sometimes uses a software menubar that takes up part of the screen.

So what I have been thinking about is that maybe I could could something like <> than values in some way and point to the already exciting settings in my fsm?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14485
  • Official Playmaker Support
    • View Profile
Re: Need help on aspect ratio handling
« Reply #3 on: October 30, 2013, 05:35:57 AM »
Hi,

 Ok, then you need to take in consideration the width and height, not the ratio.

 AND the likely best option is to have flexible layout, for example, your bottom or to tool bar must snap to the screen size, not being defined as absolute pixels.

 What UI toolkit are you using?

bye,

 Jean

Slater

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: Need help on aspect ratio handling
« Reply #4 on: October 30, 2013, 01:52:56 PM »
Thanks for replying Jean. Well we are not using any UI toolkit.

How do other people sort this out? We have a fixed size on the background and all the objects. All I do with this aspect manager is to change the viewport size depending on what device aspect ratio it is. So we have all important objects in the "center" of the image and then "cut" away stuff around it depending on the aspect ratio. So basically all I would need is to know what values I need to program for, ie 16:9 etc and set that. But obviously Android is making this problem because of the soft menu.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14485
  • Official Playmaker Support
    • View Profile
Re: Need help on aspect ratio handling
« Reply #5 on: October 31, 2013, 12:41:34 AM »
Hi,

 Ngui and other 2d frameworks comes with widgets called "anchor" and let you stick a gameobject in various screen positions ( top left, bottom right, center, etc), and they adjust with any screensize, that's a very very powerful way to describe your ui so that you limit problems with screen sizes variations.

 Also, GUI Texture comes with a relative screen transform position, that may help you as well ( play with a guitexture x  and y position to see how it relates to the screensize).

 Unity GUI also has some tools to do that, for example, if you create a full screen vertical guilayout, and in there have a flexible space then a button, that button will stick to the bottom.

Bye,

 Jean
bye,

 Jean

Slater

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: Need help on aspect ratio handling
« Reply #6 on: October 31, 2013, 01:18:42 AM »
But how do they handle the background? I mean how do those tools make the camera correspond with the background image? Right now I don't have any problem with placing the objects or changing the camera viewport to different settings in order to get the right look and placement. The only problem I have is to know what screen size values I need to put in as values to change for. Or what inbetween values I could use to say if the value is between 0.75-0.7 (not sure that is correct value though, just an example) set the camera to "this value".

I don't want to stretch the background.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14485
  • Official Playmaker Support
    • View Profile
Re: Need help on aspect ratio handling
« Reply #7 on: October 31, 2013, 02:41:44 AM »
Hi,

 Could you share the background in question? maybe you can cut it down and recompose it in game? that's usually what I do if I need flexibility. Else you will have to compromise, either by cropping/clipping or providing a background for each ratio, based on the real screen estate and not the device own ratio ( for top bar substraction)

bye,

 Jean

Slater

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: Need help on aspect ratio handling
« Reply #8 on: October 31, 2013, 02:59:27 AM »
What we do now is have the background be "bigger" than the camera viewport and change the viewport depending on the known device aspect ratio values we know about.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14485
  • Official Playmaker Support
    • View Profile
Re: Need help on aspect ratio handling
« Reply #9 on: October 31, 2013, 03:01:54 AM »
Hi,

I would also, make the margin much bigge ( the image width and heigth is bigger but the content stays centered and of the same size), then you won't have any clipping to do.

bye,

 Jean