Device Resolutions

When developing an app it is important to understand the devices you are targeting, as this will impact the way your app is developed. Consideration must be given to supporting portrait, landscape or both orientations and how your app will look on different devices.

First of all you need to determine whether you are more comfortable dealing with virtual resolutions or the percentage system. Using a virtual resolution can complicate matters and for users getting started it's probably easier to deal with the percentage system. To enable this call the command SetDisplayAspect at the start of your program, passing in the aspect ratio of the device -

width#  = GetDeviceWidth ( )
height# = GetDeviceHeight ( )
aspect# = width# / height#
SetDisplayAspect ( aspect# )

An alternative approach that achieves the same objective is -

SetDisplayAspect ( ( GetDeviceWidth ( ) + 0.0 ) / ( GetDeviceHeight ( ) + 0.0 ) )

Adding 0.0 to the values returned by GetDevideWidth and GetDeviceHeight results in the division dealing with floating point values, meaning you don't need to declare extra variables and convert integers to floats.

Calling SetDisplayAspect as shown above will ensure you app covers the full screen of the device. Try some tests by displaying sprites or text at different areas of the screen to see how this works.

Ideally test your app on your development device and use SetWindowSize to see how it looks and if necessary make any alterations for particular aspect ratios. In some cases your monitor may not support the resolution of the target device, in which case you can simply lower the resolution while maintaining the aspect ratio to determine how your app will look. For example the iPhone X has a portrait resolution of 1125 x 2436. You could divide both values by 2 to give a test resolution of 562 x 1218, thus allowing you to see how your app might look on this particular device.

The resolution of devices can vary greatly. Here's a few examples of iOS devices -