PDA

View Full Version : yet again confused


whitegriffin
01-23-2002, 04:25 AM
hey all im sure most of u forums leaders have read posts on my game and i have run ino yet another porblem i have enemys and u shoot them k on hit they go and play a movie clip to show that they die (like blood) but if u shot them again when there playing the mc the replay the mc again heres my script for the bullet:

onClipEvent (load) {
_root.mysound2 = new Sound();
_root.mysound2.attachSound("die");
laserMoveSpeed = 50;
this._x = _root.spaceship._x+32;
this._y = _root.spaceship._y-70;
}
onClipEvent (enterFrame) {
if (this._name<>"laser") {
this._x += laserMoveSpeed;
if (this._x>600) {
_root.spaceship.laserCounter--;
this.removeMovieClip();
}
for (i=1; i<=_root.numEnemy; i++) {
if (this.hitTest(_root["enemy"+i])) {
_root.mySound2.start();
_root.score += 100;
_root["enemy"+i].gotoAndPlay(2);
_root.spaceship.laserCounter--;
this.removeMovieClip();
}
}
}
}

thanks
(the code got messed up with copy and paste )

Jesse
01-25-2002, 01:18 AM
Try chaging this:
_root["enemy"+i].gotoAndPlay(2);
to this:
if (!_root["enemy"+i].dead) {
_root["enemy"+i].gotoAndPlay(2);
_root["enemy"+i].dead = true;
}
That sets a variable when the enemy is killed and it wont run the anim if the enemy is already dead.

whitegriffin
01-25-2002, 01:27 AM
ok i did that but now u can olny kill the first 4 or so enemys then the bullet wont kill any others, but it work for the first 4 guys

Jesse
01-25-2002, 01:29 AM
The variable it sets is local. It should have no effect on the other enemies. Unless they are made using duplication on the killed clips.

whitegriffin
01-25-2002, 01:42 AM
here ill just give u the fla file gamehard.fla (http://www.geocities.com/thewhitegriffin/gamehard.fla)

Jesse
01-25-2002, 02:02 AM
Wel that link is busted but I got the file and figured it out anyway. Just put this on frame one of the enemy MC:
this.dead = false;
Since you're using the same clips over and over you have to reset the life variable when the next stream of enemies come in. Nice game.

whitegriffin
01-25-2002, 02:27 AM
but now its just back to mormalk and if u hit the guys more than once they dont die(and link works)

Jesse
01-25-2002, 02:45 AM
As far as I can tell it's fine... It's attached

whitegriffin
01-25-2002, 04:06 AM
ok here the swf file linked game (http://www.geocities.com/thewhitegriffin/game.swf)

check it ut for urself

Jesse
01-25-2002, 04:16 AM
Crap, it's too b ig to attach. OK check out www.actionscript.org/help/whitegriffin/

Jesse
01-25-2002, 04:50 AM
Mine doesn't do that, see the FLA I linked above, when you publish that it doesn't let you shoot the baddies more than once.

whitegriffin
01-25-2002, 05:12 AM
i was wondering.... thanks a lot though