{"id":1215,"date":"2009-01-24T08:07:04","date_gmt":"2009-01-24T12:07:04","guid":{"rendered":"http:\/\/www.mrsunstudios.com\/?p=1215"},"modified":"2022-05-29T08:23:30","modified_gmt":"2022-05-29T12:23:30","slug":"tutorial-make-a-rhythm-game-in-as3-part-7","status":"publish","type":"post","link":"http:\/\/www.mrsunstudios.com\/blog\/flash\/tutorial-make-a-rhythm-game-in-as3-part-7\/","title":{"rendered":"Tutorial: Make a Rhythm Game in AS3 &#8211; Part 7"},"content":{"rendered":"<div class=\"toc\">\n<ol>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3\/\">The Brainstorming<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-2\/\">Create the Required Symbols\/Art<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-3\/\">Programming the Arrows<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-4\/\">Programming the Arrows Part 2<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-5\/\">Make a Level<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-6\/\">Scoring<\/a><\/li>\n<li class=\"c_chap\"><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-make-a-rhythm-game-in-as3-part-7\/\">Finishing Touches<\/a><\/li>\n<\/ol>\n<\/div>\n<h3>Step 7: Finishing Touches<\/h3>\n<p>Well, now for the last step, adding the finishing touches. Just like in my previous tutorial, I won&#8217;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.<\/p>\n<p>We haven&#8217;t displayed the score to the user yet, so we&#8217;ll do that first. It&#8217;ll be mad easy. Just create a dynamic text field (make sure to embed the font) and set the &#8220;Instance Name&#8221; field to <tt>txtScore<\/tt>. Of course, when you do this, and error pops up because of the <tt>for<\/tt> loop that we have. To fix this, just create an entire MovieClip called <tt>mcText<\/tt> and place all of the dynamic textfields in there.  I&#8217;ll leave the rest of the coding to you for this.<\/p>\n<p>We also have to show the <tt>scoreString<\/tt>. We can also do this with a dynamic text field. This time, however, the &#8220;Instance Name&#8221; field should be set to <tt>txtScoreString<\/tt>. Also, we&#8217;ve got to set the scoreString to &#8220;Bad&#8221; whenever the user misses the arrow or hits it at the wrong time. Hopefully you can figure out yourself how to do that yourself.<\/p>\n<p>Now, to show the combo to the player. We first have to define a <tt>combo<\/tt> 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&#8217;t. Then, we can just place a dynamic text field that shows the combo where ever we want.<\/p>\n<p>Next, we&#8217;re going to have a win screen and a lose screen. Just make two frames, one labeled &#8220;win&#8221; and the other labeled &#8220;lose&#8221;. Have the user navigate to &#8220;win&#8221; when the game is over, and to &#8220;lose&#8221; when the user loses. It&#8217;s pretty straightforward. If you want to, you can display the stats. Then, make a button that will navigate back to the menu.<\/p>\n<p>Finally, there is one last thing to do. If you haven&#8217;t noticed, whenever we start a game, the arrows don&#8217;t work unless you click on the background first. Simply add this code to the top of the &#8220;game&#8221; frame to fix it:<\/p>\n<pre lang=\"actionscript\">\r\nstage.focus = stage;\r\n<\/pre>\n<p>Well, now we&#8217;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.<\/p>\n<h4>Final Product<\/h4>\n<p><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"550\" height=\"400\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"src\" value=\"http:\/\/www.mrsunstudios.com\/obj\/tuts\/rhythm-as3\/pt7\/source.swf\" \/><embed type=\"application\/x-shockwave-flash\" width=\"550\" height=\"400\" src=\"http:\/\/www.mrsunstudios.com\/obj\/tuts\/rhythm-as3\/pt7\/source.swf\"><\/embed><\/object><\/p>\n<p><a href=\"http:\/\/www.mrsunstudios.com\/obj\/tuts\/rhythm-as3\/pt7\/source.zip\">Source Files (zipped)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Brainstorming Create the Required Symbols\/Art Programming the Arrows Programming the Arrows Part 2 Make a Level Scoring Finishing Touches Step 7: Finishing Touches Well, now for the last step, adding the finishing touches. Just like in my previous tutorial, I won&#8217;t really go into much description in this section, in hopes that you can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,8,4,6,68],"tags":[25,8,19,18,68,70,69,11],"_links":{"self":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1215"}],"collection":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/comments?post=1215"}],"version-history":[{"count":3,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1215\/revisions"}],"predecessor-version":[{"id":1225,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1215\/revisions\/1225"}],"wp:attachment":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/media?parent=1215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/categories?post=1215"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/tags?post=1215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}