ShiVa3D
Handling different resolutions and aspect ratios
Google Play Store, Amazon Kindle, Nook, and so many moreHandling different resolutions and aspect ratios
by astrachan » 27 Jun 2012, 22:30
Hey guys
I'm testing Shiva for developing 2D games for Android devices (and perhaps iPhone). As you know there is a huge amount of smarphones and tablets with different resolutions and aspect ratios. I was looking for some information on how Shiva supports the developer to write an application that automatically looks good on every device, once build. And somehow I couldn't find any reliable information.
Some solutions to fit the aspect ratio are adding black bars at the left and the right part of the screen (letterbox) or zooming in and cropping some parts of the application. For higher resolutions you could provide alternative graphics. Are there build-in solutions for this? How do you solve this problem?
Thanks for advice
P.S. I'm using the free web version of shiva which I downloaded yesterday, so I'm pretty much a newbie
I'm testing Shiva for developing 2D games for Android devices (and perhaps iPhone). As you know there is a huge amount of smarphones and tablets with different resolutions and aspect ratios. I was looking for some information on how Shiva supports the developer to write an application that automatically looks good on every device, once build. And somehow I couldn't find any reliable information.
Some solutions to fit the aspect ratio are adding black bars at the left and the right part of the screen (letterbox) or zooming in and cropping some parts of the application. For higher resolutions you could provide alternative graphics. Are there build-in solutions for this? How do you solve this problem?
Thanks for advice
P.S. I'm using the free web version of shiva which I downloaded yesterday, so I'm pretty much a newbie
- astrachan
- Fresh Boarder

- Posts: 2
Re: Handling different resolutions and aspect ratios
by capiright » 28 Jun 2012, 06:23
There are various ways to handle multiple resolutions:
1. Liquid UI: Place GUI elements relative to the main screen. If you are using containers you can mix relative and absolute aspect ratio on components. Just make sure to test it on your different ratios.
I found the following scheme most helpful: Root container: relative to entire screen -> Component container: Aspect ratio independent -> component element: relative to component container.
2. Multiple HUDs: You can create several copies of the same HUD and when you create them (hud.newTemplateInstance(..) ) give them the same reference name, thus your code will be unified.
3. Validate aspect ratio: use the system and application API calls to get aspect ratio information. You can use that to load a specific HUD or create some placement algorithms
1. Liquid UI: Place GUI elements relative to the main screen. If you are using containers you can mix relative and absolute aspect ratio on components. Just make sure to test it on your different ratios.
I found the following scheme most helpful: Root container: relative to entire screen -> Component container: Aspect ratio independent -> component element: relative to component container.
2. Multiple HUDs: You can create several copies of the same HUD and when you create them (hud.newTemplateInstance(..) ) give them the same reference name, thus your code will be unified.
3. Validate aspect ratio: use the system and application API calls to get aspect ratio information. You can use that to load a specific HUD or create some placement algorithms
You know you like us...
http://www.facebook.com/SunDriedGames
http://www.facebook.com/SunDriedGames
-

capiright - Platinum Boarder

- Posts: 516
Re: Handling different resolutions and aspect ratios
by astrachan » 29 Jun 2012, 22:05
Thank you very much! I will try this.
You mentiond the api calls at 3). Do you mean that I can get the height and width of the device. If so, how to do that (you could provide a link to a tutorial)? And is it also possible to get the screen-density?
You mentiond the api calls at 3). Do you mean that I can get the height and width of the device. If so, how to do that (you could provide a link to a tutorial)? And is it also possible to get the screen-density?
- astrachan
- Fresh Boarder

- Posts: 2
Re: Handling different resolutions and aspect ratios
by broozar » 30 Jun 2012, 06:40
resolution: http://www.stonetrip.com/developer/doc/api/system#Screen
screen pixel aspect ratio: http://www.stonetrip.com/developer/doc/api/system-getCurrentScreenPixelAspectRatio
density: no.
screen pixel aspect ratio: http://www.stonetrip.com/developer/doc/api/system-getCurrentScreenPixelAspectRatio
density: no.
4 posts
• Page 1 of 1