How could I do this with Defold?

Thank you.

Listen to window_resized message in the render script

And post a message from there to your scene script that it should relayout itself based on new window width/height. Recalculate all positions and apply them to your gameobjects/gui elements.

3 Likes

Additionally, if there is any data used to create nodes, for example texts, hp, xp, and so on you need to repeatedly store those in some module to be able to recover them at the reorientation. This is problematic, and I don’t like the fact that the whole GUI data is reloaded :confused: That’s why I’m still omitting applying this solution, because maybe there will be another solution that do not force us to recover this data by ourselves

1 Like

I am not working with GUI, just game objects, but I don’t recreate them on resize, just reposition and at maximum resize. I don’t think you would need to recover data for that.

1 Like

Do I need to resize the canvas when the window_resized message received?

I think, you need GUI Layouts - this is a feature for creation of a few different UI for different screen resolution or orientation.

But for the game field you need to recalculate position manually.

I use it here, for example: Classic Solitaire Klondike

9 Likes