PDA

View Full Version : Vertical Shooter Game Question



nixthinx
February 12th, 2007, 02:10 AM
Hello - This might be simple for most of you but I am trying to understand the posted game:
http://www.kirupa.com/developer/actionscript/vertical_shooter4.htm

I want to know what makes the dragons disappear? There is no remove movieclip for the dragons.

Can someone please help me understand. Thanks.

Sara

SacrificialLamb
February 12th, 2007, 02:32 AM
but there is a remove movieclip and on the page you posted too


function initDragons() {

for (i; i<dragons; i++) {

attachMovie("dragon", "dragon"+i, i);
dragon = _root["dragon"+i];
updateDragons(dragon);
dragon.onEnterFrame = function() {

if (this.hitTest(arrows)) {

score += 5;
trace(score);
arrowActive = false;
removeMovieClip(arrows);////////////////// yes there is
updateDragons(this);

}
if (this._x>0) {

this._x -= this.velo;

} else {

updateDragons(this);

}

};

}

}
initDragons();
function updateDragons(which) {

which.gotoAndStop(random(4));
which._x = random(100)+530;
which._y = random(80)+20;
which.velo = random(10)+2;

}

*ashamed* that was pathetic I'm sorry

nixthinx
February 12th, 2007, 06:22 PM
Where?

I dont see removeMovieClip(dragons);
Sorry - my expertise is basic and am trying to understand the script. Can someone be more helpful than just paste the same script in the response.

Thanks. S

brentley_11
February 12th, 2007, 06:32 PM
It doesn't remove the dragons. It checks to see if they are off screen and if so they are moved back to the beginning.

nixthinx
February 12th, 2007, 07:32 PM
Thanks Brentley, but how about when the arrow hits the dragons? They are still on the screen. How do they disappear then?

Thanks, S

brentley_11
February 12th, 2007, 07:52 PM
When an arrow hits a dragon, the arrow is removed with removeMovieClip and the dragon is moved back to the beginning just like if they go off screen.

It's the updateDragons function that is reseting them if that helps explaining things.

nixthinx
May 5th, 2007, 09:45 PM
Thank you Brentley! - Sara



When an arrow hits a dragon, the arrow is removed with removeMovieClip and the dragon is moved back to the beginning just like if they go off screen.

It's the updateDragons function that is reseting them if that helps explaining things.