• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code How to scale screen resolution on mobile devices?

S

Spiker

Guest
The script I used to scale the resolution in 1.4 doesn't work anymore. Does anyone know how it works now?
 
S

Spiker

Guest
Would you post your script using "code" tags?
Sure, this is my resize Script and it is placed in Game Start event

switch(os_type)
{
case os_android:
cur_width = max(1,display_get_width());
cur_height = max(1,display_get_height());
break;
}
switch(os_type)
{
case os_windows:
cur_width = max(1,window_get_width());
cur_height = max(1,window_get_height());
break;
}
var ratio = cur_width/cur_height
if cur_width < cur_height
{
__view_set( e__VW.WView, 0, min_height * ratio )
__view_set( e__VW.HView, 0, min_height )
}
else
{
__view_set( e__VW.WView, 0, min_width )
__view_set( e__VW.HView, 0, min_width / ratio )
}
__view_set( e__VW.WPort, 0, cur_width )
__view_set( e__VW.HPort, 0, cur_height )
surface_resize(application_surface, __view_get( e__VW.WView, 0 ), __view_get( e__VW.HView, 0 ))
 
G

Guest

Guest
You can use code tags by typing the left bracket "[" and then the word "code" and then the right bracket "]" and then at the end you type "/code" inside the brackets, and it shows your code like this:

Code:
switch(os_type)
{
case os_android:
cur_width = max(1,display_get_width());
cur_height = max(1,display_get_height());
break;
}
switch(os_type)
{
case os_windows:
cur_width = max(1,window_get_width());
cur_height = max(1,window_get_height());
break;
}
var ratio = cur_width/cur_height
if cur_width < cur_height
{
__view_set( e__VW.WView, 0, min_height * ratio )
__view_set( e__VW.HView, 0, min_height )
}
else
{
__view_set( e__VW.WView, 0, min_width )
__view_set( e__VW.HView, 0, min_width / ratio )
}
__view_set( e__VW.WPort, 0, cur_width )
__view_set( e__VW.HPort, 0, cur_height )
surface_resize(application_surface, __view_get( e__VW.WView, 0 ), __view_get( e__VW.HView, 0 ))
 
S

Spiker

Guest
I didn't know that thanks :)

Do you have any idea on what do I need to change in order to make it work?
 
G

Guest

Guest
There are a couple odd things. Your code calls a script called "__view_set()" to set the width and height. That is the first odd thing; I need to see that script to know what it's doing. The second odd thing is that you are sometimes feeding that script two variables--"min_height" and "min_width" that haven't been set in your code. So, they are either set somewhere else or not set at all, which would cause problems.
 
G

Guest

Guest
Oh, and you're also using a script called __view_get(). So, please post that as well.
 
S

Spiker

Guest
Oh, and you're also using a script called __view_get(). So, please post that as well.
IM not, GMS 2 automatically changed my code to this when I imported it.
 
Last edited by a moderator:
G

Guest

Guest
GMS2 added these as compatibility scripts--see here. So, you should have them somewhere, presumably under "scripts" in the resource tree. But if it's a built-in compatibility script, I bet it's complicated and the chances of me personally being able to help are probably pretty low. But hey! Just for fun, why not post them so we can see what they're doing?
 
Top