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

ouzzgame

Member
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!!!!
YOU CAN ONLY MULTIPLY BY AN INTEGER NUMBER (1, 2, 3...).

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...
 
Top