Creating a Vertical Shooter - Page 3
       by Ernesto Quezada aka _Bruno : January 22 2006

Now that we finished up the code explanation on the previous page, let's starting making our game more realistic.

Adding a Background
Now we are able to move our sprite, but our sprite is "in the air." We will fix that by adding a background.

To add a background is easy as you already know. Just add another layer in the main timeline and draw your background (I drew mine in Freehand and pasted it into Flash):

If you don't have time to create a background, a giant colored rectangle should suffice for now.

Drawing the Arrow
The arrow can be drawn in Flash as well (I used Photoshop to draw mine).  If you take a look at my FLA, you will see the arrow movie clip and image in the Library. Whether you create your own arrow, or use my arrow, just ensure that your arrow is inside a movie clip. The arrow should be a movieclip and we should leave it in the library, not on the stage.

Open the Library (Ctrl + L) and right click the arrow movieclip so you can open the Linkage Properties box. From the Linkage Properties dialog box, if you tick in linkage options Export for Actionscript by default the identifier will be arrow, so leave it like that.

Getting back to the Code
Let's modify the code we added in the previous page. Let's add to the script a couple of variables: one to declare the speed of our arrow and another to allow us to shoot one arrow at a time. Now, we also need a function to update our arrow.

Now the script look like:

//---- variables ----
var steps:Number = 5;
var spriteX:Number = 265;
var spriteY:Number = 265;
var speed:Number = 25;
var arrowActive:Boolean = false;
//---- functions ----
function checkKeys() {
if (Key.isDown(Key.RIGHT) && spriteX<510)>40) {
spriteX -= steps;;
if (Key.isDown(Key.UP) && arrowActive == false) {;
attachMovie("arrow", "arrows", 8);
arrows._x = spriteX;
arrows._y = spriteY+50;
arrowActive = true
function updatePawel() {
knight._x = spriteX;
knight._y = spriteY;
function updateArrow() {
if (arrowActive == true) {
arrows._y -= speed;
if (arrows._y<-10) {
arrowActive = false;
this.onEnterFrame = function() {

Onwards to the next page!

page 3 of 4


SUPPORTERS:'s fast and reliable hosting provided by Media Temple.