GML [SOLVED]Text being drawn way off mark

Zahk

Member
So in the Draw GUI event of an object, I have the code:

Code:
draw_text_ext(obj_player.x, obj_player.y, obj_player.x, -1, 50000);
Which, as far as I can tell, should draw the value of the player's x position at the player's x/y coordinates. However, it instead draws the text about 14 pixels left and 40 pixels up from the player's x position.

I haven't changed the text alignment anywhere, and I've made sure obj_player's origin is where it should be, so I really have no idea why it's not printing the text at the player's origin point.

Any ideas?
 

SoVes

Member
you're drawing from the room coordinates to the GUI/screen coordinates. basically 0 is top left of the window, but with room coordinates it's not the same. If your view is not the size of the room it will not be on the same position. so you need to figre out the top left of the cameras coordinate and subtract that from the player coordinate to get the spot on the screen.
 

Zahk

Member
Right, okay, that's what I thought. So I have this variable:

Code:
display_scale = (display_get_gui_width() / camera_get_view_width(view_camera[0]));
And when I include that variable in the draw_text code like this:

Code:
draw_text_ext((obj_player.x - camera_get_view_x(view_camera[0]))*display_scale, (obj_player.y - camera_get_view_y(view_camera[0]))*display_scale, display_get_gui_width(), -1, 50000);
it works fine when I have the window set to its base size of 160x144, or when I have it set to 3x at 480x432... but when I maximize the window to 1920x1080, the text doesn't appear on screen at all.

I'm guessing it's just something to do with maximizing the window? Because the text also appears at the same spot when I set the window size to 960x864.

Update: When I manually change the window size by dragging/maximizing the window, OR when I use the window_set_size() function to change the size of the window, the text disappears from the position it should be.

But when I just change the window size by editing the Viewport Properties in the room properties window, the text appears in the usual position.

What causes this?

EDIT: Never mind! I just fixed it with the display_set_gui function!
 
Last edited by a moderator:
Top