Mr Giff
Member
So I have a problem that just started occurring when I was developing a button for a new UI system I'm working on.
The button is supposed to be 156px by 45px and have text in the middle describing the state; pretty simple. But instead it looks like this:
Strange....
So here's my code stack:
Create Event:
Step Event:
Draw GUI Event:
And then the Global Left Press and Left Release events change the variable 'left_click' to True or False respectively.
I have one script:
I was originally drawing the surface just to the size of the button but I wasn't seeing anything.
I figured it must've been my code somewhere so decided to troubleshoot with a basic object that draws a simple rectangle on the application surface in the Draw event using the following:
Same issue, the size and the position are WAY off. Surface or no surface. I also tried fiddling with the Mac OS Graphics and Scale settings but nothing sparked a change.
I tried creating a blank GM Project but the same problem occurred. I tried quitting GMS2 and opening it again but nope. Then I restarted my computer entirely and still nothing.
I'm at a loss as to why this might be happening as I've drawn rectangles thousands of times lol.
Any help would be greatly appreciated!
The button is supposed to be 156px by 45px and have text in the middle describing the state; pretty simple. But instead it looks like this:
Strange....
So here's my code stack:
Create Event:
Code:
// Visual Variables
c_normal = make_colour_rgb(140, 173, 250); //Light Blue
c_hover = make_colour_rgb(113, 231, 221); //Light Green
c_press = make_colour_rgb(100, 204, 195); //Dark Green
colour = c_normal;
alpha = 1;
c_text = c_white;
// Size
width = 156;
height = 45;
// State
state = 0;
left_click = false;
// Text String
text[0] = "Normal";
text[1] = "Hover";
text[2] = "Pressed";
// Initialize Surface
var dispwidth = display_get_width(), dispheight = display_get_height();
surf = surface_create(dispwidth,dispheight);
Code:
/
// Responsive
x = responsive(0,5.5);
y = responsive(1,5.5);
// Colour & State
if point_in_rectangle(mouse_x,mouse_y,x,y,width,height) {
switch left_click {
case false:
colour = c_hover;
state = 1;
break;
case true:
colour = c_press;
state = 2;
break;
}
} else {
state = 0;
}
Code:
// Set the Surface Target
display_set_gui_maximize();
surface_set_target(surf);
//Draw the Button
draw_set_colour(colour);
draw_set_alpha(alpha);
draw_roundrect_ext(x, y, width, height, 11, 11, 0);
//Draw the Text
var htext = (width / 2), vtext = (height / 2);
draw_set_colour(c_text);
draw_set_halign(fa_center);
draw_text(htext, vtext, text[state]);
// Reset the surface and Draw
surface_reset_target();
draw_surface(surf, 0, 0);
I have one script:
Code:
/// @description Returns desired position based on display width divisions
/// @param Mode:width(0)-height(1)
/// @param Point(1-12)
//Initialize variables
var mode = argument[0], point = argument[1];
var width = display_get_gui_width(), height = display_get_gui_height();
var pos;
switch mode {
case 0: pos = (width / 12) * point; break; // Width
case 1: pos = (height / 12) * point; break; // Height
}
return pos;
I figured it must've been my code somewhere so decided to troubleshoot with a basic object that draws a simple rectangle on the application surface in the Draw event using the following:
Code:
draw_set_colour(c_red);
draw_rectangle(x,y,156,45,0);
I tried creating a blank GM Project but the same problem occurred. I tried quitting GMS2 and opening it again but nope. Then I restarted my computer entirely and still nothing.
I'm at a loss as to why this might be happening as I've drawn rectangles thousands of times lol.
Any help would be greatly appreciated!
Last edited: