-
-
Notifications
You must be signed in to change notification settings - Fork 18
string_width
CryoEagle edited this page Dec 26, 2018
·
2 revisions
Returns the width in pixels of a given string.
string_width(str)
Argument | Description |
---|---|
string str
|
The string to measure the width of |
Returns: Real
This function will return the width (in pixels) of the input string. It is very handy for calculating distances between text elements based on the total width of the letters that make up the string as it would be drawn with draw_text using the currently defined font.
Example:
var ww;
ww = string_width(str_Name + " ");
draw_text(32, 32, str_Name));
draw_text(32 + ww, 32, "has won the game!");
The above code will get the width of the given string and then draw two lines of text, using the returned string width as a separator.
Back to strings