• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

How I scale my game on all iOS device based on the screen ratio.


GM Version: 2
Target Platform: iOS
Download: N/A
Links: nil

How to manage the display of your game without risk of image distortion and without having black borders?
The most important thing to know is the notion screen ratio.
It is the width divided by the height.
The size of the camera must have the same ratio as your screen.

But the ratio is not everything!!!!

As you can see on the image below, the 32x32 image resized to 40x40 have both the same ratio...= 1. But the 40x40 image is distorted because half a pixel doesn't exist!!! To go from 32 to 40, you had to multiply by 1.25! Impossible!!!!

pixel perfect.png

To make it simple, if your camera is 320 wide, you can only resize it by multiplying its size by an integer if you don't want to distort the image.

In my case, my camera is 320 wide and I will calculate its height to fit the ratio of the screen that displays the image.

So, i create an object that once placed in the room will manage the display.

This is the small piece of code...
Capture d’écran 2020-07-15 à 22.51.13.png

Now, my game works perfectly on all iOS devices...