• 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!

GML Text moving left and right when counter counts [SOLVED]

OnLashoc

Member
How do I stop the text from shifting left and right as my counter hits certain numbers or double digits?

There's this funky left and right movement of my text as I press the next turn button and the date and time increases.

This is in the Draw Event:
Code:
draw_text (x + 250, y + 45 , "Date: " + string(year) + "." + string(day));
draw_text (x + 425, y + 45 , "Turn: " + string(turn));
I tried googling but I cant seem to find the answer.

Onnie
 

Rob

Member
This is down to draw_set_halign. The default setting is fa_centre so the longer/shorter the string the more it will move left or right.

use draw_set_halign(fa_left) or draw_set_halign(fa_right) before your draw code.
 

OnLashoc

Member
Thank you, and how to I change it back for the rest of the text in my game? I remember watching a tutorial on this about a year ago but I forgot.


*EDIT*

Nevermind, just had to add draw_set_halign(fa_center); AT THE END of the code needing aligned left or right to change everything else back to center aligned. Thanks again Rob, you're always willing to help, much appreciated. I searched and searched to see where I found that before but couldn't find it.

My code looks like this now and everything is as it should be:

Code:
draw_set_halign(fa_left);
draw_text (x + 250, y + 45 , "Date: " + string(year) + "." + string(day));
draw_text (x + 425, y + 45 , "Turn: " + string(turn));
draw_set_halign(fa_center);
 
Last edited:
  • Like
Reactions: Rob
Top