i am making a game for mobile with the base resolution as 1080x1920 (9 by 16 ratio) but i realized that most phones nowadays are 18:9 or even higher. my game focuses on aesthetics alot so i dont want to have these black borders on the top and bottom. one solution would be to get a larger background and change heiight to fit the screen but then there would be this empty space at the top and bottom with no action and i dont really want it to have it either because it relies on taping and frankly no one would want to tap that high anyways. the other problem is that with this, my gui woulnt be at the absolute top if someone has a higher display (i want to be the gui with the health etc to be at the top as like in most games). is there any workarounds for, i am also willing to have different builds for different ratios if possible, any ideas??
I develop my game to desktop, but supporting multiple resolutions is important in desktop too.
I have a huge “at the beginning of the scene” group to repositioning (and resizing if needed) game elements depending on the resolution. the good thing is, you should do this only once per scene. but you have to do it!
So is there a condition for it do i have to use the screen height condition?
as I wrote I’m targeting desktop, so I’m not sure how it works on mobile.
what I do is a simple math. for example the title is a text object. without condition (because this event is a sub event of the “beginning of the scene”) I just do:
- set X position of title to: (ScreenWidth /2) - (title object width /2)
- set Y position of title to: Screenheight /20
so this will position the title center on X, and almost the top on Y.
this is a great solution for the buttons and text etc but another problem i forgot to mention is that the player gets destoroyed when it touches the “boundary” i have placed outside the screen, if i set it to change height then the boundary will still be in its previous location, is it possible to their position too. and sorry for all the questions
of course, if the mentioned boundary is an object. you can set the position of all objects. but of course each situation ha its own mathematical formula.
k thanks brother appreciate the help