1. En el room, marcar "enable the use of views"
2. En View0, marcar "visible when room starts"
3. Crear un objeto llamado obj_ratio
4. En el evento CREATE, Ponerle este codigo:
///Initialize
//initialize variables
globalvar scale_multiplier;
scale_multiplier = 0;
first_run = 0; //for the alarm
globalvar HEIGHT;
globalvar WIDTH;
//initialize window size
//get width and height of screen
HEIGHT = display_get_height();
WIDTH = display_get_width();
//make view 0 fit screen
view_hview[0] = HEIGHT;
view_wview[0] = WIDTH;
view_hport[0] = HEIGHT;
view_wport[0] = WIDTH;
//make window fit screen
window_set_size(WIDTH, HEIGHT);
window_set_fullscreen(true);
//set alarm to set the game window again
alarm[5] = 5;
5. En el evento ALARM5, ponerle este código:
///Change the view[1] to fit the screen based on aspect ratio.
//get width and height of screen
test_height = HEIGHT
test_width = WIDTH
HEIGHT = display_get_height();
WIDTH = display_get_width();
//test the screen size to see if it A) changed, or B) hasn't been fully initialized
if ( ( HEIGHT != test_height ) or ( WIDTH != test_width ) or ( first_run == 0 ) )
{
first_run = 1;
//make view fit screen
view_hview[0] = HEIGHT;
view_wview[0] = WIDTH;
view_hport[0] = HEIGHT;
view_wport[0] = WIDTH;
//make window fit screen
window_set_size(WIDTH, HEIGHT);
window_set_fullscreen(true);
//make view normal again
//test the screen's aspect ratio relative to the play area's aspect ratio
if ( ( HEIGHT / view_hport[1] ) <= ( WIDTH / view_wport[1] ) )
{
/*
if the height relative to the play area's height is smaller
than the width relative to the play area's width, then
the multiplier for the screen is based on the height
this way, it stretches to fill the screen up to the height,
similar to the "Maintain Aspect Ratio" option in the
Windows module
*/
scale_multiplier = ( view_hport[0] ) / view_hport[1];
}
else
{
/*
if not, it's based on width, again like the Maintain Aspect Ratio
option in the Windows module.
*/
scale_multiplier = ( view_wport[0] ) / view_wport[1];
}
//this actually changes the play area's size
view_hport[1] = view_hport[1] * scale_multiplier;
view_wport[1] = view_wport[1] * scale_multiplier;
//this sets the position of the play area to the center of the screen
if ( ( HEIGHT / view_hport[1] ) <= ( WIDTH / view_wport[1] ) )
{
view_xport[1] = ( WIDTH / 2 ) - ( view_wport[1] / 2 );
view_yport[1] = 0;
}
else
{
view_xport[1] = 0;
view_yport[1] = ( HEIGHT / 2 ) - ( view_hport[1] / 2 );
}
}
//run the test of the first few lines again in 5 steps.
//if the screen size hasn't changed then nothing should happen
alarm[5] = 5;
6. En el evento DRAW del objeto controller, agregar al final este código
if ( view_current != 1 ) //this way we don't waste resources or have graphical errors
{
exit;
}
draw_self();
No hay comentarios:
Publicar un comentario