PDA

View Full Version : Game Help?


idle65
06-16-2001, 09:56 AM
I have a basic space shooter as created from a tutorial on flashkit. The same enemy is randomly duplictated over and over again. Is there some code that will allow me to stop this duplication?
The code on the enemy is
onClipEvent (load) {
function reset () {
this._x = 600;
this._y = random(100)+50;
enemySpeed = random(4)+1;
this.gotoAndStop(1);
}
reset();
}
onClipEvent (enterFrame) {
if (_root.spaceship.scrollStart) {
this._x -= enemySpeed+_root.mainGround.groundSpeed;
} else {
this._x -= enemySpeed;
}
if (this._x<-10) {
reset();
}
if (this.hitTest(_root.spaceship)) {
_root.gotoAndStop("gameOver");
}
}
Thanks
Dave

Jesse
06-16-2001, 10:47 AM
that code doesn't control the duplication... you'll have to edit the code which does... please use [ code ] and [ /code ] tags for forum neatness when possible.

idle65
06-16-2001, 11:39 AM
sorry i think this may be it. It is contained on the first frame of the main timeline

numEnemy=3;

for (i=2; i<=numEnemy; i++){
enemy1.duplicateMovieClip( "enemy"+i, i+100 );

}

Jesse
06-16-2001, 11:46 AM
yeah that's the duplicate code but it only makes 1 (or maybe 2) duplicate(s)... if more are being made there must be more script which is looping back to that frame...

idle65
06-16-2001, 11:56 AM
this code is what duplicates and loops the movie clip i followed it from a tutorial at

http://www.flashkit.com/tutorials/Games/Building-David_Do-611/more4.shtml

thanks
dave

Jesse
06-16-2001, 02:48 PM
I'm going to bed now and in them orning I only answer new threads since I last looked, do me a favour and reply this thread so it's considerred new when I wake up :)

idle65
06-16-2001, 02:51 PM
k

idle65
06-16-2001, 06:35 PM
i have worked out i need some way to stop this duplicating happening but how?

sky_doq
06-17-2001, 11:41 AM
Did you already considered a Stop action after the loop ?

if not stop, then make it with a variable which loops it once, then set the variable to another number and then it stops looping.

like this: ( not in actionscript, but the wat it should be )

if myvar = 0

loop the duplicate action, then set myvar to 1 and it should stop

bye

JJ

idle65
06-17-2001, 11:44 AM
thanks for all your help i have now fixed my problems