PDA

View Full Version : [AS2] Shooting the Aliens with a Gun


seekerofknowledge
09-24-2008, 06:25 AM
Hi,

In a flash game I shoot Aliens with a gun. Aliens keep dropping from the sky & I keep shooting. To make aliens disappear when hit with a bullet, i use hitTest() inside a 'if condition' and also use removeMovieClip().

I populate the bullets and aliens with two arrays namely;
newMc[] and bulletArray[].

The problem is whena a HIT is occured; the aliens wont disappear. no idea why. can somebody help. the code is in AS2:

Also pl. chk the attached .txt file

for (j in newMc)
{
_root.newMc[j]._y += 3;

if (_root.bulletArray[j].hitTest(_root.newM... {
_root.newMc[j].removeMovieClip();
}

}

Hackor Pickel
09-24-2008, 05:53 PM
when i do stuff like that, i usually make another frame in the enemy mc and label it "dead" or "hit" or something like that, and i use _root.this.gotoAndStop("dead");
instead of removeMovieClip();
hope i helped =/

xdeath
09-25-2008, 01:20 AM
that only works in some cases. if your making a "fake" dead lookw ere they dis appear and go back to how they were at the start of there life cycle then yes it would work. but if your using functions like "create a movieclip" then it will just start causing lag.
my best guess is you dragged a movieclip on the stage and are trying to remove it with a function. well i would reccommend using the delete function because the remove function only works when your creating them on the stage were as i take it you just placed it there so the delete function would be your best shot i think.

Hackor Pickel
09-26-2008, 05:06 PM
well im 14 and new to ac >__<
i do things the simple way =[