Different orientation on different platforms?

Hi everybody!

I was wondering how to approach to have both orientations (landscape and portrait) in one project, so that they would be applied accordingly to different platforms. For example, in a web top-down space shmup game: landscape on desktop and portrait on mobile. Another example would be a mobile, portrait game that should have a desktop demo. Should we keep two codebases for that? :confused:

As far as I know, game orientation is being decided on the base of display settings in game.project → depending on which is bigger: display height or width. But we cannot alter these settings in runtime (which is understood). I also think display layouts don’t help here :thinking:

Have you encountered similar dilemma?

1 Like

Actually, my story was such, that I wanted to release on itch.io a demo of a portrait mobile game and had to keep two codebases for this which got hairy later. Any ideas on how to avoid it?

Dynamic orientation should in general work out of the box. Make sure the Dynamic Orientation checkbox in game.project Display settings is checked. If checked the width and height will flip values when orientation changes.

GUI scenes can automatically adapt to this change: GUI layouts in Defold

You can also listen for this change using window.set_listener() and your render script will also automatically adjust.

It’s not exactly what I wanted, because with Dynamic Orientation the game could be played in both orientations on mobile, and I wanted to lock it in Portrait (for mobile). I want the orientation to be dependant on the platform.

When using bob.jar to build the game (locally or on CI), you can specify more than one settings file. It allows you to apply android specific settings depending on feature

java --jar bob.jar ... --settings=debug.ini --settings=mobile.ini --settings=portrait.ini

This functionality is not yet available in the editor.

1 Like

One fairly common solution is to pause the game and show a screen telling the player to rotate their phone:

1 Like

Thank you both for the answers. I like especially the Bob path, as it seems like a real solution to this. As an afterthought, I realized also, that I can change manually these two fields in settings if I found Bob too daunting. Looks like there’s no problem anymore. :handshake: