[Solved] Resize window not being detected

When I resize window in debugger, the message is not sent.

local CAMERA_GO = "/camera"  -- path to your camera GO
local design_width = 1280
local design_height = 720

local function set_camera_fill()
	local window_width, window_height = window.get_size()

	local scale_x = window_width / design_width
	local scale_y = window_height / design_height
	local scale = math.max(scale_x, scale_y) -- fill screen

	go.set_scale(vmath.vector3(1/scale, 1/scale, 1), msg.url(CAMERA_GO))
end

function init(self)
	set_camera_fill()
	print("Initial camera scale set")

end

function on_message(self, message_id, message)
	-- check for the message
	if message_id == hash("window_resized") then
		print("w_r")
	end
end

this “print(“Initial camera scale set”)” being called

Do you have this set: window.set_listener() ?

1 Like

that worked but i wonder why this doesnt work” https://defold.com/ref/stable/render-lua/#window_resized

All of that is for .render_script, not for .script or .gui_script.

Thanks

1 Like