Legacy GM [SOLVED] View and Port Not Behaving Consistently

X

xvicarious

Guest
Hey. I'm on Studio 1.4, and I'm building for Android.

In my room, when I set the parameters for:
View in Room
x = 0, y = 0, w = 320, h = 180
Port on Screen
x = 0, y = 0, w = 2560, h = 1440
It displays correctly in the correct aspect ratio, 16:9.
I used "show_debug_message", and got the following output:
Code:
03-09 12:14:42.191 14213 14231 I yoyo    : view_{x,y}view[0]: 0,0
03-09 12:14:42.191 14213 14231 I yoyo    : view_{w,h}view[0]: 320,180
03-09 12:14:42.191 14213 14231 I yoyo    : view_{x,y}port[0]: 0,0
03-09 12:14:42.191 14213 14231 I yoyo    : view_{w,h}port[0]: 2560,1440
However when I use the script I wrote to set the settings, it doesn't display correctly with black bars on the left and right.
Code:
var displayHeight = display_get_height();
var displayWidth = display_get_width();
var displayAspect = displayWidth / displayHeight;
var display_tiles_width = 10;
view_hport[0] = displayHeight; view_wport[0] = displayWidth;
view_wview[0] = display_tiles_width * 32; view_hview[0] = view_wview[0] / displayAspect; 
view_object[0] = obj_player;
view_visible[0] = true;
view_enabled[0] = true;
The output of my "show_debug_message" is identical to that of the above.
 
You can't change port in code, unfortunately.

Port only works by setting it in the first room of your game in the room editor view settings tab for that room.

I recommend watching my tutorial on this topic on my youtube channel.

 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You can't change port in code, unfortunately.
Yes you can! That's one of the fundamental parts of doing resolution scaling... There are a number of GMS1.4 articles I wrote that cover this on the YYG website.

http://www.yoyogames.com/blog/65
https://www.yoyogames.com/blog/66
https://www.yoyogames.com/blog/67

EDIT: Apart from that, and just so you can see the issue resolved, you need to call window_set_size() and set it to the size of the new viewport and also set the size of the application surface using surface_resize() to the size of the view (not the port). Also make sure you don't have "Keep aspect ratio" ticked in the global game settings.
 
Last edited:
X

xvicarious

Guest
I figured it out. If you want to change the port in code, you need to call "surface_resize" on the application_surface.
 

TheouAegis

Member
If you change the size of the window and not the size of the viewport then your view wouldn't scale up with the new window size.
 
If you change the size of the window and not the size of the viewport then your view wouldn't scale up with the new window size.
Oh really? I didn't know that window_set_size() took into account your view_port size and automatically resized your application surface. Is that true? I knew that if you don't ever change your gui size it will automatically resize your gui, but I didn't know it worked for app surface. That would be pretty cool.
 
Top