M
Midastouch
Guest
Hello everyone,
I did a little code to zoom in and out, and move the camera in my room, with the code bellow :
The code works perfectly but now my button don't works (i used a simple object with mouse collision)
For you what is the best way to create a button on the GUI (a button you can click on it, a button which don't move)?
I did a little code to zoom in and out, and move the camera in my room, with the code bellow :
GML:
vx = camera_get_view_x(view_camera[0]);//retrieve the x position of the view for a given camera
vy = camera_get_view_y(view_camera[0]);
vxx = camera_get_view_width(view_camera[0])//retrieve the width (in pixels) of the given camera
vyy = camera_get_view_height(view_camera[0])
//this is change the zoom based on scolling
//if camera_get_view_width<room_width && vyy<room_height {
zoom_level = clamp(zoom_level + (((mouse_wheel_down() - mouse_wheel_up())) * 0.1), 0.5, 2);
//}
//Set the rate of interpolation
var rate = 0.2;
//Get new sizes by interpolating current and target zoomed size
new_w = lerp(vxx, zoom_level * default_zoom_width, rate);
new_h = lerp(vyy, zoom_level * default_zoom_height, rate);
//Get the shift necessary to re-align the view.
var shift_x = camera_get_view_x(view_camera[0]) - (new_w - vxx) * 0.5;
var shift_y = camera_get_view_y(view_camera[0]) - (new_h - vyy) * 0.5;
///Horizontal scroll/////////////////////////////
if device_mouse_x_to_gui(0) < 100 && device_mouse_x_to_gui(0) > 0 {shift_x -= 10}
if device_mouse_x_to_gui(0) > (default_zoom_width-100) && device_mouse_x_to_gui(0) < room_width {shift_x += 10}
///Vertical scroll///////////////////////////////////////////
if device_mouse_y_to_gui(0) < 100 && device_mouse_y_to_gui(0) > 0 {shift_y -= 10}
if device_mouse_y_to_gui(0) > (default_zoom_height-100) && device_mouse_y_to_gui(0) <= room_height {shift_y += 10}
//Update
camera_set_view_pos(view_camera[0], shift_x, shift_y);//update the position of the camera view within the room
camera_set_view_size(view_camera[0],new_w,new_h)//update the size of the view camera within the room
//Clamp your view in the room
camera_set_view_pos(view_camera[0],
clamp( camera_get_view_x(view_camera[0]), 0, room_width - camera_get_view_width(view_camera[0]) ),
clamp( camera_get_view_y(view_camera[0]), 0, room_height - camera_get_view_height(view_camera[0]) )
);
The code works perfectly but now my button don't works (i used a simple object with mouse collision)
For you what is the best way to create a button on the GUI (a button you can click on it, a button which don't move)?