Game Development Reference
In-Depth Information
Scrolling Text (Vertical)
You've seen it at the end of a movie, where they call it the end credits : several rows of text listing
the people involved in making the flick. We can do this in much the same way as horizontally
scrolling text (see the previous feature).
Start with: Reference/Framework/space1.gmk
Creating the Vertically Scrolling Text
1. Create a new font for the end credits and give it the name fnt_endcredits . Select Times
New Roman as the Font and set it to Bold with Size 16 .
2. Create an object and give it the name obj_endcredits . Set the Depth to -1000 .
3. Add a Create event, include an Execute Code action, and insert the following lines:
1: {
2: credits = "The#Game Maker's#Companion###written by##Jacob ";
3: credits += "Habgood#Nana Nielsen#&#Martin Rijks##with ";
4: credits += "artwork by##Kevin Crossley####";
5: credits += "This is example text for scrolling end credits.#";
6: credits += "Feel free to add as many lines as you want.#";
7: credits += "The end credits will wrap once#";
8: credits += "the last line of the text has disappeared#";
9: credits += "from the screen...";
10: y = room_height;
11: vspeed = -1;
12: }
This script sets a string variable called credits containing the text to scroll. Just like in
the horizontally scrolling feature, the text is broken up over several lines using the +
operator. Note that it is a single line of text, but you can use the hash character ( # )to
indicate where you want a new line when you draw the text on the screen. Line 10
places the instance at the bottom border of the room and line 11 sets the vertical speed
for the credits.
4. Add a Draw event and include an Execute Code action. Insert the following lines:
1: {
2: draw_set_color(c_white);
3: draw_set_font(fnt_endcredits);
4: draw_set_halign(fa_center);
5: if ( y <- string_height(credits) ) y = room_height;
6: draw_text(320,y,credits);
7: }
Lines 2-3 first set the desired color and font. Line 4 makes sure the lines of text are
centered to the draw position rather than using the draw position as the top left
corner. You can compare this to setting the x origin of the text to the center of the text,
much like you can do with sprites.
 
 
Search WWH ::




Custom Search