Dynamic Viewport Mobile Devices

hcmk

Member
Hi, I'am an absolute beginner in GM.

I would like to adjust the view of the player according to the device aspect ratio. For example having a fix view width and see more of the room with taller devices.

viewport gm.png

If I understood correctly from the manual I should use the cameras / view port as illustrated above.

I tried to use the following code in room creation. It did not work at all. I'm sure I'm doing a lot of things wrong.

Code:
idapp = application_surface;
screen_x = display_get_width();
screen_y = display_get_height();
aspect = screen_y / screen_x;
room_x = room_width;
room_y = room_height;

camera_set_view_size(0,room_x,room_x*aspect);
view_set_hport(0,screen_y);
view_set_wport(0,screen_x);

view_x = view_wport[0];
view_y = view_hport[0];

display_set_gui_size(view_x,view_y);
surface_resize(idapp,view_x,view_y);
Any suggestions?
 
Last edited:
Top