string_wrap(str, width)Formats a string with automatic linebreaks. Download GMZ example
Using gml Syntax Highlighting
///string_wrap(str, width)
// Argument str: string to format, string
// Argument width: maximum width of the string in pixels, real
// Returns: string formatted with linebreaks
var str = argument0, width = argument1, cur_word = "", saved_pos = 1;
for (var i = 1; i <= string_length(str); i++) {
cur_word += string_char_at(str, i);
if (string_char_at(str, i) == " " || i == string_length(str)) {
if (string_width(string_copy(str, 1, i)) >= width) {
str = string_insert("#", str, saved_pos);
str = string_delete(str, saved_pos + 1, 1);
}
saved_pos = i;
cur_word = "";
}
if (string_width(cur_word) >= width) {
str = string_insert("#", str, i);
cur_word = "";
}
}
return str;
[b]string_wrap(str, width)[/b]
Formats a string with automatic linebreaks. [url=https://www.sendspace.com/file/nytbyb]Download GMZ example[/url]
[syntax=gml]///string_wrap(str, width)
// Argument str: string to format, string
// Argument width: maximum width of the string in pixels, real
// Returns: string formatted with linebreaks
var str = argument0, width = argument1, cur_word = "", saved_pos = 1;
for (var i = 1; i <= string_length(str); i++) {
cur_word += string_char_at(str, i);
if (string_char_at(str, i) == " " || i == string_length(str)) {
if (string_width(string_copy(str, 1, i)) >= width) {
str = string_insert("#", str, saved_pos);
str = string_delete(str, saved_pos + 1, 1);
}
saved_pos = i;
cur_word = "";
}
if (string_width(cur_word) >= width) {
str = string_insert("#", str, i);
cur_word = "";
}
}
return str;[/syntax]
_________________
Cliax Codec is a combination of top-down and third-person shooter. The gameplay will blend platforming, puzzle and shmup elements together to create a unique gameplay experience. You will take control of four playable characters which rise against a team that seemingly wants to take over the world - but are their motives really that cliché, or are there deeper motives behind their actions? Currently designing Chapter 1-6, 5% GOTM titles Spoiler:
Fan Art Spoiler:
|
|