Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Orientation Question - Gideros Forum

Orientation Question

NinjadoodleNinjadoodle Member
edited October 2015 in General questions
Hi guys

I have a project that supports both 'landscape' and 'portrait' orientations.

In Gideros however, I can only seem to select one or the other.

Is there a way to support both?

Thank you very much in advance!


  • I'm not sure about that, i think it can't.
    There is another way though, that is checking the accelerometer yourself, and implement orientation changing event.
  • Not through Gideros Studio, but you can enable auto rotation in Gideros and select all orientations directly in xcode.

    And in Android manifest setting orientation to sensor (although landscape sensor seems to work only on tablets in Android)
  • Thank for the help guys. I just thought of another way ...

    Would it be possible to give the user a button and let them change between 'landscape' and 'portrait'?
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2015
    You can rotate the stage :)

    Honestly I don't know and need to try it out
  • john26john26 Maintainer
    @keszegh, sorry we missed your other post!

    I think the whole issue of orientation is pretty complicated and I do think it needs to be generalised for desktop export where apps appear in a window which can be any size or shape. In that case, the window is the "device" and it can be portrait or landscape and this can change, either under program control (setWindowSize) or by the user.

    For instance, if you run the PC version of Nebula Retro: (this version was not exported by Gideros, but my own "toy" SDK, but the Lua code is essentially the same)


    go to the options menu and press the "portrait/landscape" the app's window changes size and shape. The Window (i.e. "device") toggles between portrait and landscape. I can't currently reproduce this in Gideros. I can change the app orientation (setOrientation), but not the *device* orientation in game.

    (For this reason, I disabled this option in the recent HTML5 version of Nebula which *was* exported by Gideros. see here http://apps.giderosmobile.com/nebularetro/)

    I think this can be fixed, but the first step is (IMO) to change how setWindowSize works. Currently you always put the small dimension first, e.g.


    if you want a landscape 480 wide, 320 tall window. (You must also specify LANDSCAPE_LEFT/RIGHT)

    I think this should change so the first number is always width. In that way the user can specify explicitly whether he wants a landscape or portrait window which Gideros would interpret as a landscape or portrait *device*. Gideros can then set the device orientation internally so everything is drawn correctly.
  • resurrecting an old topic, i want the user to be able to switch between 320x480 and 480x320 letterbox modes in a windows (qt) exported app, is this possible somehow?
    i tried to play with setOrientation, setWindowSize, setLogicalSize, but without success.
  • i would have thought that
    application:setLogicalDimensions(480, 320)
    would change a portrait letterbox ratio to a landscape letterbox ratio, but it does not.
    what does setLogicalDimensions do exactly? and how to change letterbox working area?
  • dear all, i'd really be interested how can one change from within gideros letterbox dimensions or actually just from landscape to portrait? (from say 1920x1080 to 1080x1920) thanks for your help.
  • hgy29hgy29 Maintainer
    I don't get what you are trying to achieve. Do you need to change window size or or logical dimensions ? How is this related to orientation ?
  • keszeghkeszegh Member
    edited September 2017
    i have a project that is 1080x1920 letterbox landscape_left in project properties, that is a landscape letterbox view of ratio 1920x1080.
    i want to change it to portrait orientation in windows exported app, that is as if it was started with orientation portrait in the project properties.

    however, application:setOrientation(Application.PORTRAIT) will not to this (as i would expect), instead it rotates the view inside the window (without rotating the window itself), and so the app will look rotated on the screen.

    of course i'm happy with any way to set to what i want, but no combination of gideros functions gave me the desired result.
  • keszeghkeszegh Member
    edited September 2017
    to illustrate my problem run the bird example with portrait property vs appending the line application:setOrientation(Application.PORTRAIT) and running it with landscape_left property. in the latter one the birds fly downwards.

    to be clear, i do not want to change the behaviour of application:setOrientation as it might brake earlier apps (of mine, too) but evidently there should be some way to achieve what i want. the only way currently is to set the thing to pixel-perfect and handle resize events, letterboxing etc. everything related to views manually, which is not a nice solution from such a simple task.
  • @hgy29, is my problem clear now? if yes, any suggestions? thanks
  • hgy29hgy29 Maintainer
    I am starting to understand... Gideros deals with three orientations:
    - hardware orientation, which is the way the screen is physically placed inside the device case
    - device orientation, which is how the device is actually held/oriented by the user
    - app orientation, which is how the developer wants its app to be shown

    In desktop, the first two are the same, and since the display is resizable window, have little meaning. But if you want your app to be displayed normally (that is not sideways nor upside down), you have to make sure app orientation is the same as device/hardware orientation, otherwise gideros will rotate your stage.

    Looking at gideros code, hardware orientation is initialized to your app's orientation on startup and initial window size is based on your logical size if actual window size is unspecified.

    Theoretically, you only need to call setWindowSize() and swap width & height to achieve what you want.
  • keszeghkeszegh Member
    edited September 2017
    setWindowSize does not do what i want.
    so some examples:
    original landscape_left:

    the same but properties set to portrait (one possibility i'd be happy with):
    a) image

    another version i'd be happy with:

    b) image

    instead what i get:
    1. setWindowSize480x320 :

    2. set orientation to portrait:

    3. set logical dimensions 480x320:


    you can see that all are letterboxed landscape while i want letterboxed portrait.

    i think intuitively setorientation should actually achieve b) while set logical dimensions should achieve a). but of course i'm happy with any workaround.
    original Screenshot 2017-09-22 11.53.08.png
    496 x 359 - 6K
    original properties set to portrait 2017-09-22 12.34.06.png
    336 x 519 - 5K
    other possible solution Screenshot 2017-09-22 12.31.51.png
    336 x 519 - 5K
    setwindowsize480320 Screenshot 2017-09-22 11.52.24.png
    336 x 519 - 5K
    setorientationportrait Screenshot 2017-09-22 11.54.00.png
    496 x 359 - 6K
    setlogicaldimensions480320 Screenshot 2017-09-22 11.55.36.png
    496 x 359 - 6K
  • hgy29hgy29 Maintainer
    Ok, so you want setWindowSize() + setLogicalDimensions(), but don't ever change orientation!
  • i agree that what you say should be a solution, but instead it gives:

    why is red dot not at the top left corner of the window, i wonder? all in all i don't understand what setLogicalDimensions does.
    Screenshot 2017-09-22 13.53.52.png
    336 x 519 - 5K
  • hgy29hgy29 Maintainer
    setLogicalDimensions() changes the size of your logical canvas, that is the max X and Y you use in Sprite:setPosition() (or rather the bottom right corner).

    So assuming your app properties are set to landscape, calling setWindowSize(480,320) will resize the window to 320x480 (dimensions are given assuming a portrait orientation as per API, that is small edge first), and it does work judging from your the screenshots.

    Now, if you set your logical dimensions to some portrait-in-landscape-mode size, such as (400,300) it should work as you expect.

    However gideros code when handling window resize seems wrong to me, it looks like width and height lack a swap when orientation is landscape.

    I would suggest you stick to portrait mode in your settings and use appropriate width and height so that it look like portrait or landscape
  • keszeghkeszegh Member
    edited September 2017
    @hgy29, according to your suggestion i hoped that starting with portrait and then setting
    application:setLogicalDimensions(480, 320)
    would be good finally, but it's not. it produces the following strange outcome (a horizontal letterbox inside a vertical letterbox inside a horizontal window):
    Screenshot 2017-09-22 20.19.07.png
    496 x 359 - 6K
  • hgy29hgy29 Maintainer
    edited September 2017
    We must accept that desktop export is buggy when it comes to resizing window. For HTML5 I changed the rules a bit: orientation settings do not affect orientation itself (content is always displayed in the natural way). I will try to make desktop export behave the same
    +1 -1 (+4 / -0 ) Share on Facebook
  • @hgy29, did you manage to make desktop export work as one expects (as you planned).

    on the other hand i tried to use application:setOrientation in an android export and even though in require i set that app can change orientation, calling setOrientation does not seem to change the placement of the (autohidden) android buttons - which i guess it should. is this a bug or i do something wrong?
  • @Ninjadoodle If you export to Android then it supports an app having both Landscape AND portrait. The flag to enable this is in the 'requires' plugin. :)
  • hgy29hgy29 Maintainer
    @keszegh, no I didn't manage to fix desktop export orienation stuff. I had a look but it is much more complex than on other targets since the code is shared with the player which has settings to change orienattion through the menu bar. This makes the code hard to follow and changes error prone.
Sign In or Register to comment.