1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

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

Discussion in 'Programming' started by OnLashoc, Feb 15, 2020.

  1. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    199
    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
     
  2. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    769
    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 likes this.
  3. OnLashoc

    OnLashoc Member

    Joined:
    Jan 15, 2018
    Posts:
    199
    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: Feb 15, 2020
    Rob likes this.

Share This Page