1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 Texts and surface_resize

Discussion in 'Programming' started by frekkanzer2, Aug 19, 2019.

  1. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    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:

    [​IMG]
    [​IMG]
     
    Last edited: Aug 22, 2019
  2. rytan451

    rytan451 Member

    Joined:
    Jun 21, 2016
    Posts:
    54
    Could you please clarify? GameMaker doesn't have a surface_resizing function.
     
  3. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    Damn, i'm sorry, I meant the function surface_resize.
    I'll edit the post immediately!
     
  4. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    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
     
  5. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    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.
     
  6. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    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.
     
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    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?
     
  8. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    Mh no, device_set_gui_maximise doesn't work. About the offset, do fonts has it? if yes, where i can set it?
     
  9. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,986
    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.
     
  10. frekkanzer2

    frekkanzer2 Member

    Joined:
    Feb 25, 2018
    Posts:
    14
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice