Game Development Reference
In-Depth Information
7.
Now return to the
End Step
event and add the following above the existing code:
1:
if( speak != text_previous )
2:
{
3:
text = speak;
4:
select = speak;
5:
6:
displayed_words = 0;
7:
displayed_index = 0;
8:
selected = true;
9:
selectable = false;
10:
timeout = false;
11:
finished = false;
12:
mouse_icon = true;
13:
alarm[1] = -1;
14:
15:
text_previous = text;
16:
}
This code checks if the speak variable has been changed by another object and sets up
the internal variables to display a string of text that is displayed one word at a time.
Notice that it also sets
alarm[1]
to
-1
just in case the timeout alarm had already been
set for the previous string of text. We wouldn't want it to time out before the entire
string has even been displayed!
8.
Now we need to add support for selectable text as well. This doesn't appear word by
word, but will need to detect when the mouse cursor is placed over the text. Add this
code in front of the existing code in the
End Step
event again.
1:
if( select != text_previous )
2:
{
3:
text = select;
4:
speak = select;
5:
6:
displayed_words = 999;
7:
selected = false;
8:
selectable = true;
9:
timeout = false;
10:
finished = true;
11:
mouse_icon = false;
12:
alarm[1] = -1;
13:
14:
text_previous = text;
15:
}
As you can see, other objects will trigger selectable text by setting the
select
variable
rather than the
speak
variable, but it operates in a similar way, other than setting the
internal variables to different values.
Search WWH ::
Custom Search