{"id":1285,"date":"2009-01-07T08:05:59","date_gmt":"2009-01-07T12:05:59","guid":{"rendered":"http:\/\/www.mrsunstudios.com\/?p=1285"},"modified":"2022-05-29T08:23:32","modified_gmt":"2022-05-29T12:23:32","slug":"tutorial-create-a-game-like-winter-bells-in-as3-part-5","status":"publish","type":"post","link":"http:\/\/www.mrsunstudios.com\/blog\/flash\/tutorial-create-a-game-like-winter-bells-in-as3-part-5\/","title":{"rendered":"Tutorial: Create a Game Like Winter Bells in AS3 &#8211; Part 5"},"content":{"rendered":"<div class=\"toc\">\n<ol>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-create-a-game-like-winter-bells-in-as3\/\">Basic Character Programming<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-create-a-game-like-winter-bells-in-as3-part-2\/\">Programming the &#8220;Bells&#8221;<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-create-a-game-like-winter-bells-in-as3-part-3\/\">Level Creation<\/a><\/li>\n<li><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-create-a-game-like-winter-bells-in-as3-part-4\/\">Scoring<\/a><\/li>\n<li class=\"c_chap\"><a href=\"http:\/\/mrsunstudios.com\/2009\/01\/tutorial-create-a-game-like-winter-bells-in-as3-part-5\/\">Finishing Touches<\/a><\/li>\n<\/ol>\n<\/div>\n<h3>Step 5: Finishing Touches<\/h3>\n<p>This part of tutorial is where we add some bug fixes and special effects. Let&#8217;s get started.<\/p>\n<p>The next bug we need to fix occurs after the <tt>mcFinalStats<\/tt> is shown on the screen. Whenever you click anywhere, <tt>mcMain<\/tt> can still jump. We can fix this no problem. Add an <tt>&& !gameOver<\/tt> to the if statement in the <tt>mcBg<\/tt>&#8216;s click function. That&#8217;s all we need.<\/p>\n<p>Now, we can add some special effects. The first one, of course, is going to be a background. First, move where we created the <tt>bellHolder<\/tt> to the top of the code. Next, add this code right below it:<\/p>\n<pre lang=\"actionscript\">\r\nvar bgHolder:MovieClip = new MovieClip();\/\/create a MovieClip to hold all bg shapes\r\nbellHolder.addChild(bgHolder);\/\/add it to the bellHolder to move with everything\r\n<\/pre>\n<p>Then, add this code to the <tt>eFrame()<\/tt> function.<\/p>\n<pre lang=\"actionscript\">\r\n\/\/creating a new shape\r\nvar mcBg:Shape = new Shape(); \r\n\/\/making random dimensions (only ranges from 1-3 px)\r\nvar dimensions:int = int(Math.random()*3)+1;\r\n\/add color to the shape\r\nmcBg.graphics.beginFill(0x333333\/*The color for shape*\/,1\/*The alpha for the shape*\/);\r\n\/\/turning the shape into a square\r\nmcBg.graphics.drawRect(dimensions,dimensions,dimensions,dimensions);\r\n\/\/change the coordinates of the particle\r\nmcBg.x = int(Math.random()*stage.stageWidth);\r\nmcBg.y = bellTop-bgHolder.y;\r\n\/\/adding the particle to bgHolder\r\nbgHolder.addChild(mcBg);\r\n\r\nbgHolder.y += 2;\/\/make bg move downward\r\n<\/pre>\n<p>Now, we notice that the background is actually in front of the main character. Do not fret, simply add this code to the bottom of everything:<\/p>\n<pre lang=\"actionscript\">\r\nMovieClip(root).setChildIndex(mcMain,MovieClip(root).numChildren-1);\r\n<\/pre>\n<p>Well, I guess that pretty much finished up everything. I hoped you learned much from my tutorial!<\/p>\n<h4>The Final Product<\/h4>\n<p><center><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:\/\/mrsunstudios.com\/obj\/tuts\/winter-bells-as3\/pt5\/source.swf\" \/><embed type=\"application\/x-shockwave-flash\" width=\"550\" height=\"400\" src=\"http:\/\/mrsunstudios.com\/obj\/tuts\/winter-bells-as3\/pt5\/source.swf\"><\/embed><\/object><\/p>\n<p><a href=\"http:\/\/mrsunstudios.com\/obj\/tuts\/winter-bells-as3\/pt5\/source.zip\">Source Files (zipped)<\/a><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic Character Programming Programming the &#8220;Bells&#8221; Level Creation Scoring Finishing Touches Step 5: Finishing Touches This part of tutorial is where we add some bug fixes and special effects. Let&#8217;s get started. The next bug we need to fix occurs after the mcFinalStats is shown on the screen. Whenever you click anywhere, mcMain can still [&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":[8,233,235,18,68,234,236,11,232],"_links":{"self":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1285"}],"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=1285"}],"version-history":[{"count":4,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1285\/revisions"}],"predecessor-version":[{"id":1352,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/posts\/1285\/revisions\/1352"}],"wp:attachment":[{"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/media?parent=1285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/categories?post=1285"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mrsunstudios.com\/blog\/wp-json\/wp\/v2\/tags?post=1285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}