Game Development Reference
In-Depth Information
Adding some text fields
Text fields are boxes that display text. You create them in Flash using the Text Tool in the toolbar, and
you have a choice of three types to choose from:
Static text is used for text that doesn't change and is the type of text that you've been using
until now in the storybook project. Use static text for instructions, button labels, or titles that
you expect to remain the same throughout the program.
Dynamic text is a text field that can be programmed so that the text it displays changes based
on what's happening in the program. (In other words, it changes the text dynamically .) Dynamic
text is used to display the program's output.
Input text is a text field that allows the user to type in some text. The user can then enter that
text into the program, usually by clicking a button. Logically enough, input text is used for the
program's input.
In the number guessing game, you'll use a dynamic text field to display the game's instructions and the
status of the game as it progresses. Just below the dynamic text field you'll add a large input text field
to allow players to type in the number that they think might be the mystery number.
Creating dynamic text
Let's first create the dynamic text field, which is the multiline text field. Multiline text fields are more
than one line of text high. As you develop the game in later steps, you'll use the second line of the text
field to display game status information that will be useful for the player.
1. Select the Text Tool in the toolbar.
2. In the Properties panel, select Dynamic Text from the Text type drop-down menu.
3. In the Character pane of the Properties panel, choose the font family, color, style, and size that
seem appropriate.
4. In the Paragraph pane, click the Align left button from the Format options. (If it's already selected,
you can leave it as is.)
5. In the Behavior drop-down menu from the Paragraph pane, select Multiline no-wr ap. Choosing
multiline is important so that the text field knows that it needs to display text on more than
one line. (Wrapping is what happens when text is automatically carried over to a new line when
it reaches the right-hand margin.) The no-wrap option tells the text field not to force text from
the first line onto the second line if the text from the first line is too long. You can definitely
experiment with the other option, Multiline (which does wrap text onto the next line), but it
sometimes has some quirky, unexpected results with long text that you don't want to be con-
cerned with debugging in this project. You'll just keep the text wrapping off and make sure that
the text field is long enough to display the maximum length of text.
Search Nedrilad ::

Custom Search