How to Make a Vertical Shooter in AS2 – Part 6
Part 6: Finishing Touches
As always, the finishing touches of this game won’t be explained too much by me, in hopes that you actually can do some of this stuff by yourself. Of course, there will always be source files at the bottom if you need to clear anything up.
The first thing I want to do is show the score on the “lose” screen. That’ll be pretty easy, just add a dynamic text field there.
Next, we can make some particles move down the screen so it looks like the player is actually moving forward. We’re going to make them the same speed as the enemies. I’m actually show some code for this one, because it’s also a pretty new thing for me. We’re not going to make a MovieClip for this, we’re going to make dynamic shapes through ActionScript. First, we have to add a totalBgShapes variable to the top of the code. Next, create an empty MovieClip called bgHolder Then, here’s the code to place at the bottom of the onEnterFrame function:
//creating background particles
bgHolder.createEmptyMovieClip("bg"+totalBgShapes, bgHolder.getNextHighestDepth());
bgHolder["bg"+totalBgShapes].beginFill(0x333333); //this just determines the shape's color
bgHolder["bg"+totalBgShapes]._x = int(Math.random()*550);
gHolder["bg"+totalBgShapes]._y = -50 - bgHolder._y;
//creating 4 random points to make a random shape
bgHolder["bg"+totalBgShapes].lineTo(int(Math.random()*25), int(Math.random()*25));
bgHolder["bg"+totalBgShapes].lineTo(int(Math.random()*25), int(Math.random()*25));
bgHolder["bg"+totalBgShapes].lineTo(int(Math.random()*25), int(Math.random()*25));
bgHolder["bg"+totalBgShapes].lineTo(int(Math.random()*25), int(Math.random()*25));
bgHolder["bg"+totalBgShapes].endFill();//finishes up the shape
bgHolder["bg"+totalBgShapes].onEnterFrame = function(){//giving it some actions
if(this._y > 450 - bgHolder._y || _root.gameOver){//if it goes off the stage or game is over
//then destroy it
this.removeMovieClip();
}
}
totalBgShapes ++;
bgHolder._y += 2;
Pretty intense, eh? Well, this is a finishing touch, and most finishing touches are pretty intense. Now, we have to make it so mcMain is on top of everything with this code at the end:
mcMain.swapDepths(1000);
Also, remove mcMain when gameOver is true or else strange things will happen.
There is one final thing that I want to do before actually wrapping up this tutorial. For some reason, there is a bug where a bullet disappears for some strange reason. I think I know exactly how to fix it. When we added the bullet to the stage, we made its depth the _root.getNextHighestDepth. I’m sorry, it should actually be bulletHolder.getNextHighestDepth.
Well, that’s actually all that I really have to finish off the game. I hope you had fun making it!