Fixed Aspect Ratio: default.render wont save file? (SOLVED)

Hi guys, I tried using this example from git hub https://github.com/britzl/publicexamples/tree/master/examples/fixed_aspect_ratio/fixed_aspect_ratio to get my game to display with a fixed aspect ratio. In the default render file I selected the new render_script that I created. It allowed me to choose this option, but for some reason wouldn’t save: the little asterisk kept displaying on the default.render tab no matter how many times I tried to save it. In the game.project file the new render_script was not an option in the pop up menu (maybe because I couldn’t save the file). I just wrote the desired path over the top of the default file and this just causes the game to crash when I build/run it. I’ve tried closing and opening the defold editor a few times, but I still haven’t been able to successfully save the render_script as the file that I want to use in default.render. Any ideas what I should do? Cheers…

1 Like

You cannot modify the default.render file since it’s in the read only builtins folder. Create a new .render file in your project and select the custom render script and finally assign it in game.project.

7 Likes

cool thanks

1 Like

Is there a way that I can apply the fixed aspect ratio to the gui too?

The gui is treated a bit differently. The nodes have an Adjust Mode that specifies if they should stretch, zoom or fit. If you set the nodes (or a root node) to zoom or fit instead of stretch they should maintain the aspect ratio.

1 Like

I just tried this (all the nodes were set to fit by default to start with). The gui isn’t lining up with the rest of the game when the screen size changes with any of the options. Also when the screen size changes input to the game stops working properly. Maybe this is because of how I’ve defined how to interpret input? e.g.

if action.x > 0 and action.x <= 75 and action.y > 0 
				and action.y < 50 and self.money >= 3 then
-- do something

Any ideas on what might be going on with these two issues? Thanks.

If you’re using a .gui then I’d recommend that you use gui.pick_node() for correctly detecting user input on UI elements such as buttons.

1 Like