Fit the screen resize mode in Resolution and Rendering properties

User EntrOpy gave me this piece of JS code

const canvas = document.querySelector('canvas');
if (!canvas) return;
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
canvas.style.width = windowWidth + 'px';
canvas.style.height = windowHeight + 'px';
canvas.style.position = 'absolute';
canvas.style.left = '0px';
canvas.style.top = '0px';

You right click any event
Click add
Click Javascript code
And you paste that hole code there

In game properties
Under Resolution and rendering
In Game resolution resize mode
We choose No changes to the game size

And from this

We can go

And

So we achieved FIT THE SCREEN resizing mode

I only ask for it to be added to gdevelop
Cause many users me included wanted it for years

Seems to also work in browser

Now that i think of it
Maybe action would make more sense
So we can leave players choice
Do they want pixel perfect with black bars
Or do they want our games to fit the screen

4 Likes

Do you know any game that doesn’t keep aspect ratio?

There was a discussion on the discord recently. The user was trying to replicate how Atari 2600 rendered on CRTs, with wide (rectangular) pixels.

They needed to be able to stretch the rendering X axis only to simulate this properly, because just adjusting the assets themselves wouldn’t affect their object movement correctly.

It is the first time I’ve run into someone actively not wanting to keep to aspect ratios though, especially for only one axis.

Of course i do not
That would be outrageous idea for any game to have it















I also never seen any1 ask for it

This video is from Godot
He is switching to canvas
I bet view port option is doing nothing and is there just to prank ppl

If you want i can prepare list of games that actually have stretch/fit the screen option in their settings so any user can enable/disable it at will on the fly
Unless we can both agree i spammed here enough

I guess it was common when all screens were around 4:3 or 5:4 and I think it was a good option because it avoided black stripes without distorting visuals too much.

Screen ratios have a lot more variety now:

  • PC and TV are mostly 16:9
  • but there are wider monitors like 21:9 or even 32:9
  • I’m sure 5:4 monitors are still used by many people
  • phones have a lot of different ratios between 16:9 and 22:9 and they can be used in portrait
  • tablets have a lot of different ratios between 4:3 and 16:9

In this context, I think that black stripes is a better choice if you don’t want to handle a change of viewport size.

In that context
What what you think have anything to do with anything here?

I am asking for feature to be added in and not for taking anything away or replacing something

GDevelop aims to be an approachable game engine. To decide whether an option should be added or not, there is a balance to be found between more options and easiness to use. More options is not necessarily better.

Less options is also not necessarily better
But whatever i just gonna share it with ppl who will ask for stretch/fit to screen instead