draw_set_halign() (Game Maker)

draw_set_halign()

(Game Maker 6.1, 7)

draw_set_halign - set the horizontal alignment of text

Description

draw_set_halign ( alignment )

  • alignment - horizontal alignment: fa_left, fa_center, fa_right

draw_set_halign() sets the horizontal alignment for drawing text. It accepts as its argument one of three alignment constants: fa_left, fa_center, fa_right

By default, the horizontal text alignment is set to fa_left, which allows you to draw text as if its origin was on the left side of the text. If fa_center is used as its argument, it will allow you to draw text as if its origin is in the center of the text (top center, not exact center, see examples). If fa_right is used, it will allow you to draw text as if its origin was on the right side of the text.

Examples

Example of Use

draw_set_halign(fa_center);
draw_text(100,100,"center this");

The code in this example will draw the text as if its origin is located in the top/center of the text.

Drawing Text in the Center of a Room

draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(room_width/2,room_height/2,"Game Over");

The code in this example will draw "Game Over", centered in the room.

Related Pages

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.