Still working on my game. I’m having a little trouble with my collision test. I got everything to work, but I found that if I hit an alien more than once it keeps racking up points and sends the alien explosion animation back to frame one. I tried putting a variable into the alien movie clip to determine if the alien had already been hit or not. Then I put the following commands into my laser shot movie clip:
for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
this.shotSpeed=0;
this.play();
if(_root["enemy"+i].enemyDead="no"){
_root.score+=100;
_root["enemy"+i].gotoAndPlay( 13 );
_root["enemy"+i].enemyDead="yes";
}
}
12.}
If I hit an enemy, the laser stops and blows up, like you’d expect (lines 4 and 5). However, the alien doesn’t explode anymore. It’s not getting past the “if” statement on line 6.
I have a line in the alien movie clip for enemyDead=“no”.
thanks, that seemed to help, but now I have a different problem. Every once in awhile I’ll get an alien that is invincible. When I hit him I’ll get 100 points, so it’s getting past the if statement. But then it won’t die. Seems to be about one in 10. Here’s the code.
for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
this.shotSpeed=0;
this.play();
if (_root["enemy"+i].enemyDead==false){
_root.score+=100;
_root["enemy"+i]. enemyDead=true;
_root["enemy"+i].gotoAndPlay(13);
}
}
}
It’s like it won’t get down to the gotoAndPlay (13) line, but I know it must be because I have a sound effect on frame 13 of the alien movie clip and it plays the first time I hit one of these invincible guys.
Maybe I should just leave it be, makes the game more interesting. But it bugs me to not know what’s going on.
Also, off topic, I have a problem with the game slowing down permenently if I hold down the fire button and let loose a lot of bullets. I’m removing the bullet movie clips when they get to a certain point, so I don’t think there’s a problem with too many clips on the stage at one time.
Creating engaging and entertaining content for designers and developers since 1998.