r/gamemaker • • 1d ago

Help! Draw_Set_align resetting issues?

Post image

So, I'm following tutorials and have a recurring issue with setting text. So, it's an encouraged practise when you change text alignment to "reset" it to the defaults at the end of the event, right?

I have this code:

draw_self();

draw_set_font(ft_hud);

draw_set_valign(fa_middle);

draw_text(x + 60, y - 40, value_to_draw);

draw_set_valign(fa_top);

Where the number in the screenshot should be set to fa_middle/in line with the sprite, but seems to be set at fa-top instead? Don't know if there's something else I might have made a mistake with?

The sprite is 71x71 and takes up most of the sprite editor box if that information is helpful at all.

I can't seem to find anyone else having this issue.

19 Upvotes

8 comments sorted by

7

u/Monscawiz 1d ago

Where's the sprite's origin? What you're doing is taking a position that's +60 on the x axis and -40 on the y axis from the sprite's ORIGIN, and drawing the number so that the middle of the number is at that point.

1

u/AverageArtistReddit 1d ago

Initally the default top left. I'm messing around with the sprite origin right now but the text stays 'top aligned'.

1

u/Monscawiz 1d ago

If it's currently displaying as top-aligned in the image above, then making it middle-aligned would prevent it from even being visible, it would be even higher up...

1

u/AverageArtistReddit 1d ago

Yeah, did try that and that's kinda what happened lol

1

u/Monscawiz 1d ago

I'm... not really sure what the problem is. What exactly are you looking for?

Basically, whenever you work with text alignment, set it to whatever it is you need in that event before drawing any text. That's it. No need to reset it afterwards, because you're setting it before every time that you use it anyway.

There are no bugs relating to it that I'm aware of. If there were, they'd definitely have been found by now. Drawing text happens a lot.

Try with the default font or a common font like Arial, see what happens.

1

u/AverageArtistReddit 1d ago

Alright, yeah. I'll keep experimenting.

1

u/TheGreenSocks 1d ago edited 1d ago

Hard to tell without seeing the rest of your code, but this seems to be doing exactly what you're telling it to: vertical align to the middle and draw it 40 pixels above the instance.

Where did you get the magic numbers? You probably want to valign to middle, and add half your sprite_height instead of subtracting it?

1

u/AverageArtistReddit 1d ago

Okay. I'm following a tutorial for the numbers on the x and y- those values might work for the premise sprites you're supposed to download (I just ended up making my own rough ones).

I've managed to get a little closer with sprite_width + (sprite_width / 2) , sprite_height + (sprite_height / 2).