Game Development Reference
In-Depth Information
Collecting bugs
Now that you know how to use arrays, let's collect some bugs!
1. Create a dynamic text field named ejopnq_pekjo to display the game's instructions.
2. Create some boxes to visually display the bugs you collect. Give the boxes these instance
names: epai>kt,, epai>kt-, and epai>kt..
3. Add a ikqoa object to the stage. The mouse doesn't actually do anything in the game; it's
added as an obstacle for the player. If the player collects the mouse, the game is lost. The frog
doesn't like mice! Figure 9-25 shows what these new objects look like.
4. Save the ^qc?]p_dan*bh] file.
itemBox0
itemBox1
itemBox2
instructions
mouse
Figure 9-25. Add the instructions dynamic text field, item boxes, and mouse.
5. You need to declare an array to collect the bugs and a variable to tell you whether the mouse
has been collected. Add the following declarations at the top of the class definition:
lner]par]n[_khha_pekjF]n6=nn]u7
lner]par]n[ikqoaBkqj`6>kkha]j7
6. Initialize the array, variable, and dynamic text field in the constructor method:
[_khha_pekjF]n9jas=nn]u$%7
[_khha_pekjF]n9WY7
[ikqoaBkqj`9b]hoa7
ejopnq_pekjo*patp9?]p_d/^qcobknpdabnkc*7
 
Search Nedrilad ::




Custom Search