Categories: All Tutorials, AS3, Flash, Game Development, Intermediate Tutorials
Step 7: Finishing Touches
Well, now for the last step, adding the finishing touches. Just like in my previous tutorial, I won’t really go into much description in this section, in hopes that you can figure out how to do these without my help. As always, the source file is always available at the bottom.
We haven’t displayed the score to the user yet, so we’ll do that first. It’ll be mad easy. Just create a dynamic text field (make sure to embed the font) and set the “Instance Name” field to txtScore. Of course, when you do this, and error pops up because of the for loop that we have. To fix this, just create an entire MovieClip called mcText and place all of the dynamic textfields in there. I’ll leave the rest of the coding to you for this.
We also have to show the scoreString. We can also do this with a dynamic text field. This time, however, the “Instance Name” field should be set to txtScoreString. Also, we’ve got to set the scoreString to “Bad” whenever the user misses the arrow or hits it at the wrong time. Hopefully you can figure out yourself how to do that yourself.
Now, to show the combo to the player. We first have to define a combo variable at the top and set it to 0. Then, we have to increment it every time the user hits the right key, and reset it every time the user doesn’t. Then, we can just place a dynamic text field that shows the combo where ever we want.
Next, we’re going to have a win screen and a lose screen. Just make two frames, one labeled “win” and the other labeled “lose”. Have the user navigate to “win” when the game is over, and to “lose” when the user loses. It’s pretty straightforward. If you want to, you can display the stats. Then, make a button that will navigate back to the menu.
Finally, there is one last thing to do. If you haven’t noticed, whenever we start a game, the arrows don’t work unless you click on the background first. Simply add this code to the top of the “game” frame to fix it:
stage.focus = stage;
Well, now we’re basically done. Of course, this is just the beginning of making a game like this. You must figure out everything else on your own if you want to become a real programmer.