This is a cool function, used in a lot of professional games… with professional sound it gets really cool. One letter is added, one at a time, until there is a full sentence. It only requires one object, three events and very little coding. In create event (or anywhere else, but it should work as initialization) we put this:
full_sentence = "This is a full sentence";
alarm[0] = 1;
i = 1;
sentence = "";
I bet you already understand everything in that code, and I won’t keep you waiting, but show you the code that I use in the alarm event:
if (i<=string_length(full_sentence)) {
sentence += string_char_at(full_sentence,i);
i+=1;
alarm[0] = room_speed/3;
}
Note that I set alarm to room_speed/3, which means that I draw three characters each second. You should change this value after your need and taste. Finally I draw it in the draw event:
draw_text(x,y,sentence);
Ask if there is anything special that you would like to know.
Example (with an extra sound effect):
http://gmtutorials.com/files/letterbyletterex.gm6
.
Users logged in:
Comments
Loading comments...