Game Development Reference
In-Depth Information
5.
We will also allow the player to skip quickly through the text by jumping to the end of
the sentence after a single mouse click and automatically setting the timeout variable
after a second click. Add a Mouse, Global Mouse , Global Left Pressed event and
include an Execute Code action containing the following code:
{
if( displayed_words < 999 )
displayed_words = 999;
else
finished = true;
}
6. Now add a Draw event that draws the text. and include an Execute Code action
containing the following code:
1: {
2: vx = view_xview[0];
3: vy = view_yview[0];
4:
5: if( text == "" )
6: exit;
7:
8: draw_set_font( font_speak );
9:
10: if( selected )
11: draw_set_color( c_white );
12: else
13: draw_set_color( c_gray );
14:
15: draw_text_ext( vx+x, vy+y, displayed_text, 25, text_width );
16:
17: if( finished == true && mouse_icon == true )
18: draw_sprite( spr_mouse, global.step_count/30, vx+x+text_width+30, vy+y );
19: }
Most of this is fairly straightforward, but observe the use of the draw_text_ext function
on line 15 to draw multiple lines of text. This function automatically breaks down the
string into lines of text that are text_width long and separated by 25 pixels:
Also notice that the final two lines draw the mouse icon once the whole line of text
has finished appearing. This uses the global.step_count variable to change between
the mouse icon's two subimages once every 30 steps (1 second) while the game is
waiting for the player to click the mouse button.
Search WWH ::




Custom Search