Gasil
Member
I'm trying to draw a rectangle window in a menu system, which uses an array to store the options. The thing is that such options aren't always going to be the same, they could vary in width and height and I'd like the rectangle to match those measures.
This is the code.
I tried to use string_width(string(diagMenu)) to get the width of the strings; however it seems to give me a sum of every option. But weirdly enough for me, I did a test to check the width of a single option and it gave me the following result. I used string_width(string(diagMenu[0]))
https://imgur.com/IJlrF3r
the rectangle doesn't cover all the width of the string.
Should I use the function in another way?
This is the code.
Code:
if (alpha < 1) alpha += 0.08; else alpha = 1;
draw_set_color(c_black);
draw_rectangle(x + espacio, y, x + string_width(string(diagMenu)), y + 100, 0);
draw_set_color(c_white);
draw_set_alpha(1);
//Dibujar Texto
var m;
for (m = 0; m < array_length_1d(diagMenu); m += 1)
{
draw_text(x + espacio, y + (m * espacio), string(diagMenu[m]));
}
https://imgur.com/IJlrF3r
the rectangle doesn't cover all the width of the string.
Should I use the function in another way?