Quick Links: Gideros Home | Download Gideros | Developer Guide
Orientation Question
  • 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'?
  • You can rotate the stage :)

    Honestly I don't know and need to try it out
  • john26john26 +1 -1
    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)

    https://www.dropbox.com/s/blru13489oac7mh/NebulaRetroSetup11.exe?dl=0

    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.

    application:setWindowSize(320,480)

    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 +1 -1
    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 ?
  • 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.
  • 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 +1 -1
    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.
  • setWindowSize does not do what i want.
    so some examples:
    original landscape_left:
    image

    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 :
    image

    2. set orientation to portrait:
    image

    3. set logical dimensions 480x320:

    image


    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 +1 -1
    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:
    image

    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 +1 -1
    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
  • @hgy29, according to your suggestion i hoped that starting with portrait and then setting
    application:setLogicalDimensions(480, 320)
    application:setWindowSize(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 +1 -1 (+4 / -0 )
    Maintainer
    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

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters