How to Create a Game Like Winter Bells in AS3 – Part 5

Part 5: Finishing Touches

This part of tutorial is where we add some bug fixes and special effects. Let’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 jump. We can fix this no problem. Add an && !gameOver to the if statement in the mcBg‘s click function. That’s all we need.

Now, we can add some special effects. The first one, of course, is going to be a background. First, move where we created the bellHolder to the top of the code. Next, add this code right below it:

var bgHolder:MovieClip = new MovieClip();//create a MovieClip to hold all bg shapes
bellHolder.addChild(bgHolder);//add it to the bellHolder to move with everything

Then, add this code to the eFrame() function.

//creating a new shape
var mcBg:Shape = new Shape();
//making random dimensions (only ranges from 1-3 px)
var dimensions:int = int(Math.random()*3)+1;
/add color to the shape
mcBg.graphics.beginFill(0x333333/*The color for shape*/,1/*The alpha for the shape*/);
//turning the shape into a square
mcBg.graphics.drawRect(dimensions,dimensions,dimensions,dimensions);
//change the coordinates of the particle
mcBg.x = int(Math.random()*stage.stageWidth);
mcBg.y = bellTop-bgHolder.y;
//adding the particle to bgHolder
bgHolder.addChild(mcBg);
 
bgHolder.y += 2;//make bg move downward

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:

MovieClip(root).setChildIndex(mcMain,MovieClip(root).numChildren-1);

Well, I guess that pretty much finished up everything. I hoped you learned much from my tutorial!

Spread the Knowledge

  • Print
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Twitter
  • Google Bookmarks
  • Design Float
  • DZone
  • Yahoo! Buzz
  • PDF
  • Reddit
  • RSS
  • Technorati

Preview

Download Source
(Requires Flash CS3 or above)

Subscribe!

Subscribe!
Enter your email address:  

Awesome Tutorials