Change Window Size

I already changed the game.project>Display>Width/Height. I understand that this is the logical resolution. I’m good with how it adapts to device’s screen size / resolution. What I wanna change is the window size when I press Cmd+B (Build). Since I’m working on a laptop, the height ain’t enough to the default window size hence I get black pillars (I’m fine with the pillar as it is the result of being responsive). What I want is change the window size so I get to develop and test quickly experiences my intended aspect ratio. I can tackle the “responsive” part later on.

I tried looking for answers and found that I can display-width and display-height fields in the game.project but it didn’t work. In fact, it fails the build.

This is what I want:

This is what I’m getting by default:

I think you are looking for msg.post("@render:", "resize", { width = 960, height = 540 }) (change the values).

do I put this in the render_script? I just did this:

function init(self)
	-- Add initialization code here
	-- Learn more: https://defold.com/manuals/script/
	-- Remove this function if not needed
	msg.post("@render:", "resize", { width = 230, height = 500 })
end

It did change the window size (some milliseconds after it loads up the window) but it just shows a black screen. Where should I put this script?

I usually have in init() in the main.script, which is what I call the first script that gets loaded with the main collection.

As for your black screen, hard to say from here.

gotcha! I saw the main.script. Quick (off-topic) question, if you want to initialize the game and you put your logic in main.script. How do you guarantee that main.script will run first before other.script? In case you require to run some logic in the init() of main.script and you don’t want other.script to run before main.script.

Quick follow up, where can you find the available messages? In this case, you can send “resize” to “@render”. I saw another message - “use_fixed_fit_projection”. I tried pressing CTRL+Space to check auto-complete / intellisense but “resize” and “use_fixed_fit_projection” didn’t appear.

I usually have a bootstrap collection with an attached main.script where I do all the platform initialization. Then I load any other collection needed via collection proxy.
Proxies are a powerful concept if you think about them in terms of your states (menu, game, levels, etc)

1 Like

Update: this didn’t work. it resized the window but it resized the resolution too.

This is how it should be:

But this is what I get:

API reference (Render) Here is a list of render specific messages.

API reference (Game object) Here are go specific messages.

More to be found under other API pages.

What if you call window.set_size()?

1 Like

haha! This is it! Thanks @britzl