• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Text Draw problem

E

ersnbyrz

Guest
Hi all..

i want my texts keep place in button. Because when i select fullscreen texts going out button limits..

anyone can show me code for text focus button center and wil keep place when change roomsize..

ty all.
 
A

Aura

Guest
You'd perhaps want the text to be drawn relative to the button instead of drawing it at an absolute position.

If the button is an instance, you'd go with using x and y...

Code:
draw_text(x - 2, y + 2, "Play");
If the button is not an instance, you could go about using two variables that hold the position of the button:

Code:
var _x, _y;
//Draw button at _x, _y
draw_text(_x + 2, _y + 8, "Quit");
But the solution hugely depends on how you're handling buttons and things, so you might want to be a bit more informative in that regard if the above doesn't help.
 
E

ersnbyrz

Guest
You'd perhaps want the text to be drawn relative to the button instead of drawing it at an absolute position.

If the button is an instance, you'd go with using x and y...

Code:
draw_text(x - 2, y + 2, "Play");
If the button is not an instance, you could go about using two variables that hold the position of the button:

Code:
var _x, _y;
//Draw button at _x, _y
draw_text(_x + 2, _y + 8, "Quit");
But the solution hugely depends on how you're handling buttons and things, so you might want to be a bit more informative in that regard if the above doesn't help.

i made 10 different buttons objects on left side for use like gui and all buttons is empty i mean havent any text inside ..

After i write some draw codes in an invisible object...

Code:
x_yer= 45;  // x place setting
y_yer= 34;  // y place setting
genis= 73;   // vertical lenght

draw_set_font(fnt_benim_22);
draw_set_colour(c_white);
draw_text(x_yer,y_yer,"Karakter");
draw_text(x_yer,y_yer+(genis),"Yetenek");
draw_text(x_yer,y_yer+(genis*2),"Calisma");
draw_text(x_yer,y_yer+(genis*3),"Uretim");
draw_text(x_yer,y_yer+(genis*4),"Carsi");
draw_text(x_yer,y_yer+(genis*5),"Savas");
draw_text(x_yer,y_yer+(genis*6),"Klan");
draw_text(x_yer,y_yer+(genis*7),"Arkadas");
draw_text(x_yer,y_yer+(genis*8),"Sohbet");
draw_text(x_yer,y_yer+(genis*9),"Posta");

this codes is perfect working if window isnt fullscreen .But when i click fullscreen in game,text going wrong places :S

*codes in draw gui event
 
Last edited by a moderator:

jo-thijs

Member
The problem is that you are drawing the text in the GUI event, but not the buttons themselves.
Either draw the text in the draw event instead of the draw GUI event
or keep the buttons from being drawn in the draw event and draw them in the draw GUI event.
 
E

ersnbyrz

Guest
The problem is that you are drawing the text in the GUI event, but not the buttons themselves.
Either draw the text in the draw event instead of the draw GUI event
or keep the buttons from being drawn in the draw event and draw them in the draw GUI event.
when i write in Draw event doing this...
 

Attachments

jo-thijs

Member
In that case the value of genis should be changed when using the draw event.
You might be using views, which could change the scale on which everything is drawn from when it was drawn in the draw GUI event.
 
E

ersnbyrz

Guest
So whats way to write code for auto going to any object center??
 

jo-thijs

Member
If the middle of your button sprite is drawn at position (X, Y),
then you can draw the text in the middle of the button by:
Code:
draw_set_font(...);
draw_set_colour(...);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(X, Y, ...);
 
E

ersnbyrz

Guest
If the middle of your button sprite is drawn at position (X, Y),
then you can draw the text in the middle of the button by:
Code:
draw_set_font(...);
draw_set_colour(...);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(X, Y, ...);
ty so much for care dude but i tryed it before and my all other texts gone wrong side because its halign and valign changing my all text in my room
 
A

Aura

Guest
Perhaps reset them after you are done with them.

Code:
draw_set_font(...);
draw_set_colour(...);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(X, Y, ...);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
The same technique applies to all draw_set_*() functions.
 
E

ersnbyrz

Guest
Perhaps reset them after you are done with them.

Code:
draw_set_font(...);
draw_set_colour(...);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(X, Y, ...);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
The same technique applies to all draw_set_*() functions.

umm good idea ty bro i will try it
 
Top