Tengo una room de 980x560 y una view de ese mismo tamaño. Pero quiero que se pueda hacer zoom con los dedos, por ejemplo como clash of clans que puedes hacerle zoom a tu aldea con los dedos.
Me interesa tambien este tema, a ver si alguien sabe. Saludos.
Aquí publicaron un código para eso:
http://gmc.yoyogames.com/index.php?showtopic=541440 (http://gmc.yoyogames.com/index.php?showtopic=541440)
En los tutoriales de GMS también hay un ejemplo:
(http://i.imgur.com/gxNRdTT.png)
Es un tutorial muy corto, tal vez lo traduzca en unos días.
Cita de: Clamud en Marzo 22, 2016, 04:48:49 PM
Aquí publicaron un código para eso:
http://gmc.yoyogames.com/index.php?showtopic=541440 (http://gmc.yoyogames.com/index.php?showtopic=541440)
En los tutoriales de GMS también hay un ejemplo:
(http://i.imgur.com/gxNRdTT.png)
Es un tutorial muy corto, tal vez lo traduzca en unos días.
El tutorial de game maker no le entiendo muy bien.
Probe el codigo que publicaron en el foro de yoyogames;
CitarCreate
initial_w_view = view_wview[0];
view_scale = 1;
initial_x = 0;
initial_y = 0;
initial_zoom = 0;
Global mouse left
var view_ratio;
view_ratio = view_hview[0]/view_wview[0];
if( device_mouse_check_button_pressed( 1, mb_left ) )
{
initial_x = mean( device_mouse_x( 0 ), device_mouse_x( 1 ) );
initial_y = mean( device_mouse_y( 0 ), device_mouse_y( 1 ) );
initial_zoom =
point_distance
(
device_mouse_raw_x( 0 ), device_mouse_raw_y( 0 ),
device_mouse_raw_x( 1 ), device_mouse_raw_y( 1 )
)*view_scale;
};
if( device_mouse_check_button( 1, mb_left ) )
{
view_scale = initial_zoom/
point_distance
(
device_mouse_raw_x( 0 ), device_mouse_raw_y( 0 ),
device_mouse_raw_x( 1 ), device_mouse_raw_y( 1 )
);
view_wview[0] = initial_w_view*view_scale;
view_hview[0] = view_wview[0]*view_ratio;
view_xview[0] += initial_x-mean( device_mouse_x( 0 ), device_mouse_x( 1 ) );
view_yview[0] += initial_y-mean( device_mouse_y( 0 ), device_mouse_y( 1 ) );
};
Si me funciono pero tengo un problema. Cuando le empiezo a hacer zoom, la view se empieza a mover como si se estuviera trabando el juego :-\
Yo pude resolver el problema, pero tengo una pregunta.
Como hago para que la view no se haga mas grande que la room?
hola desplo como solucionaste para que no bibre no tiemble o como quieran llamarlo, lo de que no se pase a la rom tenes que ponerle un limite. no sabria decirte en codigo, pero seria simple, si tu tamaño_view>a tamaño_room{tamaño_view=tamaño_room} o algo similar
Cita de: josesito1432 en Marzo 22, 2016, 11:49:53 PM
hola desplo como solucionaste para que no bibre no tiemble o como quieran llamarlo, lo de que no se pase a la rom tenes que ponerle un limite. no sabria decirte en codigo, pero seria simple, si tu tamaño_view>a tamaño_room{tamaño_view=tamaño_room} o algo similar
Al contrario de usar global mouse left lo debes poner en un Step;
Pon esto:
Create
initial_w_view = view_wview[0];
view_scale = 1;
initial_x = 0;
initial_y = 0;
initial_zoom = 0;
touched = false;
Step
var view_ratio;
view_ratio = view_hview[0]/view_wview[0];
if( device_mouse_check_button_pressed( 1, mb_left ) )
{
initial_zoom =
point_distance
(
device_mouse_raw_x( 0 ), device_mouse_raw_y( 0 ),
device_mouse_raw_x( 1 ), device_mouse_raw_y( 1 )
)*view_scale;
};
if( device_mouse_check_button( 1, mb_left ) )
{
view_scale = initial_zoom/
point_distance
(
device_mouse_raw_x( 0 ), device_mouse_raw_y( 0 ),
device_mouse_raw_x( 1 ), device_mouse_raw_y( 1 )
);
view_wview[0] = initial_w_view*view_scale;
view_hview[0] = view_wview[0]*view_ratio;
if(touched = true){
view_xview[0] += initial_x-mean( device_mouse_raw_x( 0 ), device_mouse_raw_x( 1 ) );
view_yview[0] += initial_y-mean( device_mouse_raw_y( 0 ), device_mouse_raw_y( 1 ) );
}
};
if(device_mouse_check_button(1, mb_left)){
initial_x = mean(device_mouse_raw_x(0), device_mouse_raw_x(1));
initial_y = mean(device_mouse_raw_y(0), device_mouse_raw_y(1));
touched = true;
}else{
touched = false;
}