Are you saying that render.get_window_width() returns the wrong value? What is the value you have in game.project, what value does the function return, and what is the actual width?
Well, render.get_window_width() returns a value that doesn’t seem to match the GUI.
I have set the game project width to 414. The function returns width 1080 on device. Not sure about the actual width, is there a way to get the actual width of a GUI?
I thought this might be relevant, but can’t get it to work:
ps. I am actually using Orthographic camera.get_window_size(), which in turn uses render.get_window_width(). That shouldn’t matter, right?
No, not really. You can get the size of individual nodes, but that can change based on adjust mode.
No, that shouldn’t matter.
The html template will resize the canvas so that it fills out the entire screen width while maintaining aspect ratio. 1080 sounds like a screen width that you could encounter on a device. Which device are you testing on?
I created a minimal version of the project, and I’m getting nowhere. I’ll post it here as a sign of defeat, for now: StretchNodeToScreenWidth.zip (227.8 KB)
The 6T has a resolution of 1080 x 2280. So, render.get_window_width() is correct. And window.set_listener() should fire when orientation changes, but you will not be able to use it on app start to detect screen size. render.get_window_width() is the way to get the size on app start.
Yes, I figured that was the case. I’ve yet to figure out how to translate this figure to be usable with the GUI, though.
Actually, that’s not entirely true - if I set the GUI’s “Adjust Reference” to “Disabled” the size correlates to the GUI. With the huge drawback of having to code all the alignment manually. It may be that I can redesign the game input mechanics themselves, to avoid this problem!
I guess I’d have to modify the render script for this? I was hoping to use Orthographic, a tool I adore.
When I test, slice 9 objects are deformed, rather than retaining the corners nicely. How would I get them to stretch nicely when they’re stretched by Defold (rather than me setting the size manually)?