Legacy GM Texts and surface_resize

F

frekkanzer2

Guest
Hello, i have a little problem.
I have to use the function surface_resize at the start of a room. When i use that function, all texts shown on screen are shifted of 30~px in vertical. If i don't use surface_resize, all texts are shown in the normal coordinates.
How i can fix that without changing the coordinates of all the texts?
Look the example here:


 
Last edited by a moderator:
F

frekkanzer2

Guest
Damn, i'm sorry, I meant the function surface_resize.
I'll edit the post immediately!
 
F

frekkanzer2

Guest
So i've solved adding some pixels to the coordinates. That was a long work, but now it's solved.
I don't explain why it happened.
If I try to write text anyway, if I don't add the difference pixels, it still continues to make mistakes with coordinates!
Now my code is like:
draw_text(myX, myY + DIFF, myText);
where DIFF is a constant
 

TheouAegis

Member
What surface are you resizing? Are you drawing the text to the surface before resizing it? Because odds are you aren't drawing your text to the surface.

You could consider using the GUI event instead.

Or maybe you just need to change your text's vertical alignment.
 
F

frekkanzer2

Guest
What surface are you resizing? Are you drawing the text to the surface before resizing it? Because odds are you aren't drawing your text to the surface.

You could consider using the GUI event instead.

Or maybe you just need to change your text's vertical alignment.
I'm resizing the application surface;
I draw after the resize;
I use GUI draw event and the normal draw event: it depends by the situation but the problem is on each text (normal and GUI);
Ehm no, changing the vertical alignment is not a good solution: changing pixels is more precise.
 

TheouAegis

Member
If the GUI is changing position, try setting device_set_gui_maximise(1,1,0,0) after you resize the surface.

If that doesn't resolve it, then as for the alignment-vs-pixels issue, did you verify the pixel offset is unrelated to the size of the font?
 
F

frekkanzer2

Guest
Mh no, device_set_gui_maximise doesn't work. About the offset, do fonts has it? if yes, where i can set it?
 

TheouAegis

Member
The more I think about it, I don't think that's the issue. Unless you had your font alignment set to fa_bottom by default, changing it probably won't matter.

How did you calculate DIFF? is it just some arbitrary number that you measured out based on your current problem, or was it derived from an algorithm you came up with? Does it work with all sizes of application surface?

And your screenshots, where you say "with surface_resizing" and "without surface_resizing", did you add those lines of text with a text editor, or did you have your game print them out? I asked, because you say it shifts the text 30 pixels up, but the screenshot if you had gamemaker print those lines itself, shows that the text moves up on the right but down on the left.

it's further complicated by the fact that, at least on my phone, those two pictures look to be the same size, so I don't see what resizing the application service actually did. However, I am curious, when you resize it application service, did you also resize the GUI? If you do not resize a GUI layer, then any text you draw to it will probably be misaligned.

as for normal drawing, you shouldn't have that kind of an issue, at least from what I can see in the screenshots with a normal resize unless you were resizing the surface after the default draw event has already taken place. If you resize the surface outside of the BEFORE draw events, there shouldn't be any issue within normal draw events. GUI drawing is a whole other matter.
 
F

frekkanzer2

Guest
Yes, DIFF is a number measured out based on the problem. No algorithm, i've calculated it looking the difference in pixel between the case without the problem and the case with the problem. I haven't tried it with other resolutions yet :/
"with surface_resizing" and "without surface_resizing" are added with paint lol. The texts with the problem are "Red" and the numbers on the top right of the screen.
Yep, i resize also the GUI layer, without any change :/
I have been programming with GML for years, something like this has never happened to me...
What a strange problem lol
I hope that the DIFF constant will works with other resolutions, i'll let you know here lol
 
Top