draw_text_ext

This function draws text in a similar way to draw_text(), and allows you to set the space between each line of text - should the text occupy more than one line - and limit the width (in pixels) of the string per line so that should any line exceed this value, GameMaker will automatically split the text to the next line at the nearest available whitespace (if the text has no whitespaces then it will overrun this maximum width value).

Any whitespace placed at the start of the string (or at the start of a new line) will not count towards the maximum width, and will function as indentation for the line.

A value of -1 for the line separation argument will default to a separation based on the height of the "M" character in the chosen font.

 

Syntax:

draw_text_ext(x, y, string, sep, w);

ArgumentTypeDescription
xRealThe x coordinate of the drawn string.
yRealThe y coordinate of the drawn string.
stringStringThe string to draw.
sepRealThe distance in pixels between lines of text.
wRealThe maximum width in pixels of the string before a line break.

 

Returns:

N/A

 

Example:

draw_text_ext(100, 50, keyboard_string, 3, 300);

The above code will draw whatever text the user types into the keyboard, splitting it onto new lines every time the string length for that line exceeds 300 pixels. the code will also maintain a separation of 3 pixels between lines should this occur.