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 (97 points)

1 Answer

+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!

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.