Issue with ios device render resolution

How come when I rotate the device to landascape the width and height are same as in portrait mode?
Even though I set different res depending on landscape/portrait?

so when rotating horizontally, I still get width 720 when checking sys.get_config_int(“display.width”)?

I’m not sure what Display Profiles is using for but the right place for setting display size is at Display section of game.project file

Thank you, I was looking at it and it seems very useful thing to use for some GUI elements. But the thing I still don’t understand is what exactly then Display Profiles do?

For instance

sys.get_config_int(“display.width”)

Gets the width defined in game.project->Display-width

How do I reference from code the width defined in Display Profiles? I thought it was the same value, but maybe I’m wrong?

Display Profiles define certain thresholds of screen ratios that are checked by the GUI system to change layout of a GUI (for instance going from portrait to landscape):

1 Like

ahh I see, it’s only used from the GUI system then… gotcha :slight_smile:

so what would be the best approach to define different resolutions for different devices and orientation?

Like for instance I want the app to have windows set as follows:

on iPhone portrait 720x1280, landascape 1280x720
on iPad postrait 1080x1920, landscape 1920x1080

Hope it makes sense?

1 Like

You can’t control the window size on mobile. The window is the entire screen and will be sized according to the size of the display panel. A call to window.get_size() will return the actual size of the device it is running on.

BUT I think we need to come back to your initial post again:

This is not the right way to go about things when positioning GUI elements. You should position GUI elements according to the size set in game.project. If you have game.project display width and height of 640x1136 and want a GUI box node positioned dead center on the screen you set the position of the box node to 320x568.

When you launch the game the GUI will automatically adjust itself to the physical resolution of the device, but if something is positioned in the center it will remain in the center regardless of screen resolution. If you anchor something to the bottom or top it will remain there regardless of the height of the screen. And so on. The GUI will adjust to the physical dimensions according to the rules defined in the manual: GUI scenes in Defold

If you create a GUI node at runtime and want to position it in the center of the screen you need to use the display width and height, not the window width and height. So in your code it would be

x = sys.get_config_int("display.width") / 2 /2, y = sys.get_config_int("display.height") / 2 /2

Wow! I hadn’t noticed that this setting was only for the GUI.

Thank you! That’s clear now :slight_smile:
I’ve setup 2 layouts for portrait and landascape and assigned them to the GUI scene and all seems working fine. Though I don’t understand this:

I’m drawing a bounding box around the card node (just a box node with a texture assigned, same for both landscape and portrait layouts), using the msg.post("@render:", “draw_line”) and the gui.get_position and gui.get_size properties. On portrait it looks okay:

But when I rotate the device to landscape mode, the bounding box gets drawn in a wrong position and with wrong size:

Any idea why that’s happening?

The strange thing is also that when testing the builtin function gui.pick_node inside on_input, the action x and y seem getting a proper hit inside the card node.

How is the bounding box positioned? Is it a child node of the card?

The bounding box is just composed by 4 lines drawn with msg.post("@render:", “draw_line”) call, using the card node position and size (gui.get_position and gui.get_size)

the lines draw calls are all inside the update function.

Oh, ok, that will be a bit complicated. Debug lines are mostly useful when drawing lines in the game world and aligning with game objects. The GUI is different and as I told you before it will adjust itself to the screen resolution. The position you get from gui.get_position() will be in the coordinate space of the screen dimensions set in game.project while debug lines are in the actual screen size dimensions.

Thank you… I’m starting I think to get my head around this :slight_smile:

1 Like

Me again heheh

So I got mostly everything working nicely on iPhone, but today I tried to add another qualifier to the display profiles to see how it would handle a different resolution on a different device.

But when I deploy on the iPad air 4 it seems always picking the iPhone resolution qualifier.

Any suggestion?

What is the resolution of the iPad air 4 and what is the reported device model?

iPad Air 4 has 2360 x 1640 resolution and from

sys.get_sys_info().device_model

I get “iPad13,1”

That’s odd. What if you remove “iPad13,1” from the Device Models and only keep the width and height qualifiers?

Tried that, but it seems that no matter how many qualifiers in the list, the engine only always picks the first on the list.

Should I report this as a bug?

Yes please. Also make sure to include a zip file with a minimal project where this can be tested.

Thanks for the suggestion. Here’s the link to the topic created in the bugs section: