Hi, I’m trying to work through the Vertical Shooter Game within the tutorials section of this site: http://www.kirupa.com/developer/actionscript/vertical_shooter.htm.
I noticed an code error of if spriteX -= steps; (which should have been += steps)
However there are further errors within the tutorial as on page 3 where the man should be able to move and shoot his arrows, mine just shoots his arrows and has stopped moving. I’m using CS5 ActionScript3 to do this tutorial. Please could you take a look and tell me what the code should be. I HAVE to work in AS3. There may be further code errors later on. I would appreciate if someone with some knowhow could have a look. Thanks. My current code is below.
//---- 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) {
spriteX += steps;
knight.legs.play();
} else if (Key.isDown(Key.LEFT) && spriteX>40) {
spriteX -= steps;
knight.legs.play();
}
if (Key.isDown(Key.UP) && arrowActive == false) {
knight.arms.play();
attachMovie(“arrow”, “arrows”, 8);
arrows._x = spriteX;
arrows._y = spriteY+50;
arrowActive = true
}
}
function updateArrow() {
if (arrowActive == true) {
arrows._y -= speed;
}
if (arrows._y<-10) {
arrowActive = false;
removeMovieClip(arrows);
}
}
this.onEnterFrame = function() {
checkKeys();
updatePawel();
updateArrow();
};