GML Is there automatic scaling?

C

Cupid Stunt

Guest
Before I get to reinventing the wheel I want to be sure that there is not an automatic scaling system for users resizing game or browser windows.
The games that I'm currently working on should have their elements stay in the same relative position and all remain visible as the window's size is changed.
I assume that I just need to make my positions and sizes relative to the windows height, width, and aspect ratio, and then to redraw everything on a window size change. Is that correct?
To extend the question further, does this hold true for all target platforms? Are there any specific variables that will help me?

I've found the tutorial on scaling my surface in html5 and made that part work on the surface, but not the elements. I'm just asking before I redesign the entire layout to be relative, that there isn't a built-in facility to do so already.

Thanks
 

Xor

@XorDev
Here's what I do for HTML5 scaling:
Code:
//Resize the canvas, view and application surface to fill the browser
window_set_size(browser_width,browser_height);
camera_set_view_size(view_camera[0],browser_width,browser_height);
surface_resize(application_surface,browser_width,browser_height);
It makes the game fill the whole browser, fixing the scaling and aspect ratio.

To make it work on all platforms you'll probably need your own width and height variables which are set based on the target platform.
 
C

Cupid Stunt

Guest
Here's what I do for HTML5 scaling:
Code:
//Resize the canvas, view and application surface to fill the browser
window_set_size(browser_width,browser_height);
camera_set_view_size(view_camera[0],browser_width,browser_height);
surface_resize(application_surface,browser_width,browser_height);
It makes the game fill the whole browser, fixing the scaling and aspect ratio.

To make it work on all platforms you'll probably need your own width and height variables which are set based on the target platform.
I have a generator object that creates and controls all the other instances.
It is resident in the room.
I placed those three lines into the first line of it's Game Start Event.

I'm sure the way I put thing together is the problem, but is there a chance you've seen this before?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
C

Cupid Stunt

Guest
You would want to enforce camera size in every room, else the camera doesn't fill the entire screen and you might get... well, exactly what you are seeing here - out-of-camera areas do not get redrawn

Basics Of Scaling is a good read https://www.yoyogames.com/blog/67/the-basics-of-scaling-html5
I read that article the other day. I used it to create the script and object that will change the room size. Just re read it, I do not see how to enforce camera size. I only have one room, btw. Can you explain how to enforce the camera size, please?
 
C

Cupid Stunt

Guest
That
Call camera_set_view_size on room start in every room
was performed in the code provided @Xor
Now you said on room start, so I copied the code into the only room's creation code.
It's still not working, though. The results are the same.
I'm probably doing something wrong.
 

Xor

@XorDev
How are you drawing things? Are you drawing a surface in the Draw GUI event? If so you'll probably need to scale that with the viewport.
 
C

Cupid Stunt

Guest
I use instance_create_layer to place all of the objects on the same surface, then the objects control their own x and y as needed. The only thing that I do in any draw event is manage the text on the screen.
I have three layers: instance, mid-level, background. the scoreboard background is the only thing in mid-level.
I have no Draw GUI Event anywhere in the program.
 
Top