Mobile Development screen resolution and aspect ration

Hi there!

Im developing a mobile app for both android and ios and one thing ive always been uncertain about is screen resolution and aspect ratio.

The game i am developing involves characters running from one side of the screen to the other (quite simple). The solution i went for is to figure out the size of the user screen (mainly its height) i then divide that by 10 to get a value containing one tenth of the screen’s height.

using that i would then place the spawn point for my characters e.g. if i wanted a character dead center of the screen i would set their starting position to 5 * onetenth screen height.

So far this solution has worked well for me (ive tested on my mobile device and others) but what im wondering is if its a bad practice and if theres any potential problems that could occur?

The game is set to only run using landscape orientation, so changing orientations shouldn’t affect the positions.

The thing with mobile development is that you basically can’t account for the screen size. While you can find people and websites out there that will tell you specific screen sizes I would honestly avoid programming based on a specific size of screen. What happens if a new phone comes out that has a different screen size than your target platform? All of your code you wrote wouldn’t work then. That just happened with the new iPhone that came out. So doing things based on a % of the screen is the way to go. Just avoid specific sizes all together, its more headache than its worth.