0 votes

I need to make game with normal GUI that's fullscreen. But when the button is pressed, need to switch to a scene with a viewport(?) that's only 160x100 pixels. And it need to be fullscreen. As if you make a game 160x100 resolution and set stretch mode to 2d and aspect to keep. But it only needs to be that way at one scene. Because when I tried making the hole game that size, GUI get's all funked up. So I think I need to make a viewport or something, that's 160x100 and draw everything onto it, and then make it occupy all screen.
Thanks in advance

Godot version 3.2.3-stable
in Engine by (102 points)

2 Answers

+1 vote
Best answer

You can do that with the function get_tree().set_screen_stretch(). That function takes the following arguments, which can all be referenced through SceneTree constants:

StretchMode (2D, Viewport, Disabled)
Aspect (Ignore, Keep, Expand)
MinSize (Vector2(x,y))

So, what you'll want to actually change is that 3rd argument. A simple call like this on the scene's _ready() will show you whether it's working or not:

func _ready():
    get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D,SceneTree.STRETCH_ASPECT_KEEP,Vector2(160,100))

If you also want to force the screen into fullscreen, you'll have to set a OS parameter: OS.window_fullscreen = true

by (292 points)
selected by

Thanks, a life saver!

0 votes

You can set it up on design time in editor. Depend on your target is landscape or portrait.
I'd like to share some important setup for mobile to support wider screen.
1. If you use viewport don't forget to set ViewportContainer->Stretch property to "ON"
2. Camera3D->Keep Aspect to Keep Height for landscape or Keep Width for portrait.
3. Project Settings->Display->Window->Stretch->Mode to 2D
4. Project Settings->Display->Window->Stretch->Aspect to expand
enter link description here

by (22 points)
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 Frequently asked questions and 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 [email protected] with your username.