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.
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.
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.
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.
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:
the same but properties set to portrait (one possibility i'd be happy with): a)
another version i'd be happy with:
b)
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
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
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):
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
@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.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@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.
Comments
There is another way though, that is checking the accelerometer yourself, and implement orientation changing event.
And in Android manifest setting orientation to sensor (although landscape sensor seems to work only on tablets in Android)
Would it be possible to give the user a button and let them change between 'landscape' and 'portrait'?
http://giderosmobile.com/forum/discussion/6032/applicationsetdeviceorientation-#Item_1
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Honestly I don't know and need to try it out
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.
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
i tried to play with setOrientation, setWindowSize, setLogicalSize, but without success.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
- 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.
so some examples:
original landscape_left:
the same but properties set to portrait (one possibility i'd be happy with):
a)
another version i'd be happy with:
b)
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
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
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh, SinisterSoft, totebo, antix
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?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://deluxepixel.com