Game Development Reference
In-Depth Information
6. The User Defined 0 event is an event that is called when the dialogue needs to advance
to the next sequence, either as a result of a mouse click, or because of a timeout.
1: {
2: if( talking == TALK_NOONE || global.text1.finished == false )
3: exit;
4:
5: if( global.text1.selected == true )
6: {
7: sequence = next_sequence1;
8: global.text1.text = "";
9: global.text2.text = "";
10: }
11:
12: if( global.text2.selected == true )
13: {
14: sequence = next_sequence2;
15: global.text1.text = "";
16: global.text2.text = "";
17: }
18: }
It begins on lines 2-3 by checking if no one is talking or if the current sequence of text
hasn't finished displaying (one word at a time) yet. If either of these situations is true,
then it exits the script.
Lines 5-17 simply check which of the two global text objects are selected and
advances the current sequence accordingly. In both cases, the actual text strings of the
text objects are reset back to the empty string (“”) as well. Note that where there is no
choice to be made (such as when another character is talking), the first text object will
always have its selected variable set to true .
7.
The Global Left Pressed event simply calls the User Defined 0 event using the
event_perform function.
event_perform( ev_other, ev_user0 );
As already discussed, we use the User Defined 0 event to handle advancing to the next
sequence, so it needs to be called when the mouse is clicked. Of course, we could have
put that code in this Global Left Clicked event, but we will need to call the same code
from more than one place, so this allows us to do that. It's another way of achieving a
similar effect to using a script resource, if you like. You can get Game Maker to call any
event in this way—see the help file for details on the parameters for different events.
 
Search WWH ::




Custom Search