FoxyOfJungle
Kazan Games
The main problem:
As you can see in that GIF, I can scale it so that It will always stay 1:1. But I want to zoom in and out, and this is the problem. I will explain next:
I created a surface instead of using the Draw GUI event (I need to, because later I'll need to copy that created GUI surface), so the whole interface is being drawn on this surface.
Ok, As you can see from the GIF, each color represents different functions to get the mouse position, and draws a circle for each.
Notice in GIf that I zoom in and out the surface using the "resize" method. (notice the GIF that has a variable drawn on the screen called: gui_zoom, in the top left).
How I zoom in and out the surface:
global.ideal_width and global.ideal_height is the window size, same as window_get_width...
global.gui_zoom is the variable that scales the surface. (ranges from 0.7 to 2).
But, when I increase or decrease the zoom variable, the relative position of the mouse on the surface is incorrect (as you can see in GIF).
So, how do you get the mouse position relative to the surface area? (I think I will have to use the variable global.gui_zoom together)
So that the position of the mouse relative to the surface goes from 0 to the size of the surface, like the normal screen?
I created two scripts to get the mouse position relative to the surface, I want them to return like the mouse_x function:
gui_mouse_x();
gui_mouse_y();
Thank you so much!
As you can see in that GIF, I can scale it so that It will always stay 1:1. But I want to zoom in and out, and this is the problem. I will explain next:
I created a surface instead of using the Draw GUI event (I need to, because later I'll need to copy that created GUI surface), so the whole interface is being drawn on this surface.
Ok, As you can see from the GIF, each color represents different functions to get the mouse position, and draws a circle for each.
Notice in GIf that I zoom in and out the surface using the "resize" method. (notice the GIF that has a variable drawn on the screen called: gui_zoom, in the top left).
How I zoom in and out the surface:
Code:
if surface_exists(global.gui_surface)
{
surface_set_target(global.gui_surface)
draw_clear_alpha(0,0);
//This code above is on the FIRST lines of the normal draw event.
HERE WILL DRAW ALL THE GUI
surface_reset_target();
}
else
{
global.gui_surface = surface_create(global.ideal_width*global.gui_zoom, global.ideal_height*global.gui_zoom);
}
draw_surface_stretched(global.gui_surface,0,0,global.ideal_width,global.ideal_height);
//This code above is on the LAST lines of the normal draw event.
global.ideal_width and global.ideal_height is the window size, same as window_get_width...
global.gui_zoom is the variable that scales the surface. (ranges from 0.7 to 2).
But, when I increase or decrease the zoom variable, the relative position of the mouse on the surface is incorrect (as you can see in GIF).
So, how do you get the mouse position relative to the surface area? (I think I will have to use the variable global.gui_zoom together)
So that the position of the mouse relative to the surface goes from 0 to the size of the surface, like the normal screen?
I created two scripts to get the mouse position relative to the surface, I want them to return like the mouse_x function:
gui_mouse_x();
gui_mouse_y();
Thank you so much!
Last edited: