0 votes

I want to change the resolution of my "view of the game" mid-game from 1920x1080 (landscape) to 1080x1920 (portrait). The window should remain whatever size it was but different scaling should occur so that all content is visible on the screen.

So...

I made different layouts for landscape and portrait by detecting orientation and changing positions of nodes in the code. This is ok cos I don't have that many nodes.

The aspects of these layouts are 16:9 and 9:16 and I want to display them entirely so that nothing will be cropped. Added whitespace or black bars are ok.

I followed the instructions of this multiple resolutions tutorial and made my viewport a square 1080x1080. But I'm unable to make it work with any of the aspect settings.

"Keep" just forces the 1080x1080 square to be all that's showing.

"Expand" works only if the screen is high enough for portrait and wide enough for landscape. It will crop the content if the screen is portrait but not high enough or landscape but not wide enough. That's not good!

Here's a rough illustration of what I mean

I managed to get the correct behaviour with use of Camera2D and a bit of code to adjust the zoom. I was almost excited .....until I realised it ruins the scaling quality and text will start looking bad.

The same can be done with the following code by changing the resolution to 1920x1080 when the screen is landscape and to 1080x1920 when portrait. But this ruins the scaling quality as well which doesn't even make any sense!

get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_EXPAND,Vector2(1080.0, 1920.0),1.0)

So what I'm looking for is a way to change the "visible area" of the game. Normally I would call that "viewport" but any adjustments to the viewport in code will change the window size as well. So if viewport = window, what is the "visible area of the game whera all content exists" called and how to change its size mid-game?

Godot version v3.3.3.stable.official [b973f997f]
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.