Game Development Reference
In-Depth Information
Adding a button
You've got input and you've got output. Now you just need some way of getting the text from the
input text field into the program so that it can be processed. The lowly button comes to your rescue
again!
1. Create a new button symbol called Cqaoo>qppkj.
2. Drag an instance of the Cqaoo>qppkj symbol onto the stage next to the input text field.
3. Make sure that the button is still selected, and give it the instance name guessButton in the
Instance name box in the Properties panel.
4. The user interface for your game might now look something like Figure 5-10.
Figure 5-10. Add the Guess button to the GUI.
Building a simple guessing game
You'll build the number guessing game in three separate phases so that you can get a solid grasp of
the techniques before you add more complexity. The first phase is the most basic version, but it's the
most important because it contains the very heart of the game.
The game starts by asking the player to guess a number from 1 to 100. It will tell the player whether
the guess is too high or too low, until eventually the correct number is found. In this version of the
game, the player gets an unlimited number of guesses, but you'll fix that and add a few more interest-
ing features in phase 2.
Setting up the Main.as file
The I]ej*]o file is set up using exactly the same structure as the previous projects, with one striking
difference. Can you spot it?
1. Copy the following into your I]ej*]o file:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*IkqoaArajp7
lq^he__h]ooI]ejatpaj`oIkrea?hel
w
lq^he_bqj_pekjI]ej$%
w
 
Search Nedrilad ::




Custom Search