Change window size from script (SOLVED)

I’d like to be able to list some recommended window sizes in the game options. When the player selects one, the window size will change.

I’m surprised Defold doesn’t offer this, since every other engine I can think of offers it as a basic window function.

1 Like

You are able to change window size using the following message:

msg.post("@render:", "resize", { width = 1024, height = 768 } )
7 Likes

There is also DefOS if you wish to make more changes to the window, mouse cursor etc

5 Likes

Ah, I looked up how to do it in old posts and the response was that there is no way. Maybe those were outdated. Oops. Great, thank you both!

1 Like

Unless I’m missing something both render “resize” message and defos are not supported on iOS?
Is there a solution to set the window/display size at runtime on iOS platforms?

Not really. Your window/display size will always be the size of the screen itself.

But if you need “chunkier” pixels or a more zoomed in view you can ofc use a camera and apply or zoom (Camera component manual) or tell the render script to zoom (The render pipeline in Defold).

Note that window.get_size() will still report the size in pixels of the screen, even if you zoom with a camera or render script.