Tutorial: Make a Rhythm Game in AS3 – Part 7


Written By MrSun at 8:07 am - Saturday, January 24th, 2009
Categories: Flash

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.

Final Product

Source Files (zipped)

5 Comments

FlashNewbie:

Thanks that tutorial helped me out a lot with a project I’m in the middle of, I had to change a few things like the levels which I didn’t need in my case. I just altered It so there is only one level, and I made the array for that level with random numbers from 1 to 4.

var aArrows:Array = new Array();

function randomize(min:Number, max:Number):Number
{
var nRandom:Number = Math.floor(Math.random() * (max – min + 1)) + min;
return nRandom;
}

for (var i = 0; i < 16; i++)
{
var nRandom:Number = randomize(1,4);;
aArrows.push(nRandom);
}

Just putting that out there in case anyone was inteading on doing the same thing as me.


Flash Guru:

Hey, pretty cool tutorials… I need you to convert them into a different format… My school computors suck.


FirestarLeader (Flash Newbie):

I’ve got this down and all but two things,
1 is how can you make hold notes and multiple notes to play at once? and how do u change the tempo and appearance rate of each arrow?
2nd is im trying to add themes, (pics,themed arrows and such) but cant seem to acsess the level im working on. I’ve already made 2 themed levels with music and everthing, but can i import those into my game? PLZ RESPOND SOMEONE IM DESPERATE!!


Caveman:

Thanks a lot!!You’ve really inspired me =)..


rhinoforce135:

how do i add music? and how do i make it levels 1 – 8 instead of 0-4? please email me at rhinoforce135@gmail.com


«
»