Android / Amazon Fire os_lock_orientation flips my game

So I am working on an android game. I have a room where I am using the device_get_tilt as the primary controls, but with to big tilt motions the game would flip from landscape to portrait and ruin the game experince. So in order to fix this I used os_lock_orientation(false) when the room starts (in the create event of a obj spawned in the room).

Now the wierd thing is that if the game is running in landscape_flipped, then the entire game gets flipepd upside down when os_lock_orientation is run. Which is unplayable. IDK what to do, is os_lock_orientation hard coded to only have landscape and protrait, and not landscape_flipped and portrait_flipped supported?

I know I can lock my game to only landscape in the game settings, but as I am using both portrait and landscape mode throughout my application, so I need those enabled.

The code I am calling in a create event (the flipped variable is used for controls):
Code:
if(display_get_orientation() == display_landscape) {
    os_lock_orientation(true);
    flipped = false;
}
else if(display_get_orientation() == display_landscape_flipped) {
    os_lock_orientation(true);
    flipped = true;
}
 
Still strugling with this. Is there some way to rotate the entire screen 90 degress, cause that would be another solution. Just locking the phone in portrait mode and then for the necessary rooms rotate them so the player can see they have to flip their phone and then it would be locked because it was set to "portrait" only in the settings.

But I cannot find anything about rotating rooms or rotating the screen/surface. I can rotate the view angle, but that doesn't really solve it.Could really use that surface_resize would support rotation.

EDIT: I found a solution, it is super ****ty, but I need to move forward with this project. So I found out about a method called draw_surface_ext, which is able to draw a surface rotated. So I set the game to default ONLY be able to stay ijn portrait mode and then fake the landscape mode for certain rooms, by disabling the application surface and redrawing it rotated.

I have a controller object that persist through all rooms, to control edge cases on a room to room basis. This is the "Room Start" event.

Code:
if(view_enabled) {
    var resizeW = view_wview[0];
    var resizeH = view_hview[0];
}
else {
    var resizeW = room_width;
    var resizeH = room_height;
}
surface_resize(application_surface,resizeW,resizeH);

if(room == prep_tilting_boat_rm || room == tilting_boat_rm) {

    global.landscape = true;
 
    // Resize the entire screen to fix orientation
    application_surface_draw_enable(false);
    redrawX = display_get_width()-(display_get_width()-room_height)/2;
 
}
else { ...
and the this is in "Post Draw" event
Code:
if(global.landscape) {
    draw_surface_ext(application_surface,redrawX,0,1,1,-90,c_white,1);
}
You have to modify ALL your Darw GUI events as they still think it is in portrait mode.
 
Last edited:

salyossy

Member
Still strugling with this. Is there some way to rotate the entire screen 90 degress, cause that would be another solution. Just locking the phone in portrait mode and then for the necessary rooms rotate them so the player can see they have to flip their phone and then it would be locked because it was set to "portrait" only in the settings.

But I cannot find anything about rotating rooms or rotating the screen/surface. I can rotate the view angle, but that doesn't really solve it.Could really use that surface_resize would support rotation.

EDIT: I found a solution, it is super ****ty, but I need to move forward with this project. So I found out about a method called draw_surface_ext, which is able to draw a surface rotated. So I set the game to default ONLY be able to stay ijn portrait mode and then fake the landscape mode for certain rooms, by disabling the application surface and redrawing it rotated.

I have a controller object that persist through all rooms, to control edge cases on a room to room basis. This is the "Room Start" event.

Code:
if(view_enabled) {
    var resizeW = view_wview[0];
    var resizeH = view_hview[0];
}
else {
    var resizeW = room_width;
    var resizeH = room_height;
}
surface_resize(application_surface,resizeW,resizeH);

if(room == prep_tilting_boat_rm || room == tilting_boat_rm) {

    global.landscape = true;

    // Resize the entire screen to fix orientation
    application_surface_draw_enable(false);
    redrawX = display_get_width()-(display_get_width()-room_height)/2;

}
else { ...
and the this is in "Post Draw" event
Code:
if(global.landscape) {
    draw_surface_ext(application_surface,redrawX,0,1,1,-90,c_white,1);
}
You have to modify ALL your Darw GUI events as they still think it is in portrait mode.
Exactly what i need, but the rotation affects only the drawing.. if i click on an object, its not reacting.. the object is being triggered only if i touch it on its original poisition (but the object isn't displayed there, so its not usful)

is there another option? or a solution to the problem i mentioned?


🙏
 
Top