The conversation system is really just a bunch of functions placed in the game time-line, not a proper set of classes. Remember that at this time the system is more or less a prototype and should be thought of as a kludge rather than a proper system. The heart of the system is the converseClear function which resets the system. From there the main text and individual options are set before the whole conversation is started with a call to converseStart().
function converseClear()
{
var cntr;
quick_btn._visible = false;
converseDelayCounter = 0;
converseDelay = 5;
converseMainText = ".";
converseTextPos = 0;
converseTotalBubbles = 0;
converseNumBubblesShown = 0;
for (cntr = 0; cntr < converseBubbles.length; ++cntr)
{
converseBubbles[cntr].hideBubble();
}
onEnterFrame = null;
}
function converseSetText(s)
{
converseMainText = s;
}
The options that the player has are represented by bubbles. I am cheating in this prototype in two ways. First, the number of bubbles is 5 because that is the most I need. Second, the final bubble is always a square box that represents an action that the player can take.
function converseAddBubble(s, id)
{
converseBubbles[converseTotalBubbles].initBubble(s, this, ootw24event, id);
++converseTotalBubbles;
}
Once all the calls for setting up the conversation have been made, conversations are started by simply making the “quick text” button visible and setting the enterFrame event to the converseUpdate function.
function converseStart()
{
quick_btn._visible = true;
onEnterFrame = converseUpdate;
}
The enterFrame function is set to converseUpdate until all the conversation elements have been shown. First, the text is drawn one character per frame. Once the main text has finished being shown, the “quick text” button is show and the options start to be displayed. Once all the options have been made visible, the enterFrame function is set to null to reflect that no event is needed.
function converseUpdate()
{
if (converseTextPos < converseMainText.length) {
++converseTextPos;
main_txt.text = converseMainText.substring(0, converseTextPos);
} else if (converseNumBubblesShown < converseTotalBubbles) {
quick_btn._visible = false;
++converseDelayCounter;
if (converseDelayCounter >= converseDelay) {
converseDelayCounter = 0;
converseBubbles[converseNumBubblesShown].showBubble();
++converseNumBubblesShown;
}
} else
onEnterFrame = null;
}
Quick text is handled the same way as the old system. Clicking on the quick text button simply calls a function that sets the text position to the end of the sentence so the next frame will display the entire paragraph.
function converseQuickText()
{
converseTextPos = converseMainText.length - 1;
}
Previous page | Chapter 24 Page 5 |
About -
Privacy Policy -
Contact -
Links -
FAQ
Copyright © 2008 Blazing Games Inc. All Rights Reserved