# Enemy help?

**URL:** <https://forum.kirupa.com/t/enemy-help/266791>\
**Category:** Uncategorized\
**Created:** [July 24, 2008, 11:55am UTC](https://forum.kirupa.com/t/enemy-help/266791 "2008-07-24T11:55:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam\_vickery](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@sam\_vickery](https://forum.kirupa.com/u/sam_vickery)\
**Post date:** [July 24, 2008, 11:55am UTC](https://forum.kirupa.com/t/enemy-help/266791/1 "2008-07-24T11:55:38Z")

</div>

I have made this game which is like stick defense. I have made 2 enemies and can get one enemy to come on the screen but cant seem to get the other one to. I cant attach the file as it is too big but here is the code I used. thanks

I am new to flash and dont know much and the code I have given wasnt written by me.

\_root.onLoad = function() {  
//starting a timer to make spawn frequently  
\_root.archerstartTime = getTimer();  
//this is just a var to set the names and depths  
\_root.archerenemyCounter = 0;  
//creating a delay for the enemy spawn  
\_root.archerdifficulty = 2000;  
//loading the cursor in a higher depth than the enemies  
\_root.attachMovie(“cursor”, “cursor”, 1000);  
\_root.cursor.\_xscale=70  
\_root.cursor.\_yscale=70 //starting a timer to make spawn frequently  
\_root.swordstartTime = getTimer();  
//this is just a var to set the names and depths  
\_root.swordenemyCounter = 0;  
//creating a delay for the enemy spawn  
\_root.sworddifficulty = 2000;  
};  
\_root.onEnterFrame = function() {  
//this is other var to see the current time  
\_root.swordcurrentTime = getTimer();  
//for each delay time a new enemy is spawned  
if (\_root.swordcurrentTime-\_root.swordstartTime\>=\_root.sworddifficulty) {  
//setting the enemy number  
\_root.swordenemyCounter++;  
//putting the enemy on stage  
\_root.swordcurrentEnemy = \_root.attachMovie(“swordenemy”, “swordenemy”+\_root.swordenemyCounter, 500+\_root.swordenemyCounter);  
//putting the enemy in the right place of the stage!  
\_root.swordcurrentEnemy.\_y = random(150)+150;  
\_root.swordcurrentEnemy.\_x = -100;  
//I think they are too big… resizing  
\_root.swordcurrentEnemy.\_xscale = 17;  
\_root.swordcurrentEnemy.\_yscale = 17;  
//this line says: “-come back in one second”  
\_root.swordstartTime = \_root.swordcurrentTime;  
//setting max dificulty(spawning frequency)

}  
//for each 30 seconds we will clear our index  
if (\_root.swordcurrentTime-\_root.swordstartTime\>=30000) {  
//this will make names repeat  
\_root.swordenemyCounter = 0;  
//this is other var to see the current time  
\_root.archercurrentTime = getTimer();

//for each delay time a new enemy is spawned  
if (\_root.archercurrentTime-\_root.archerstartTime\>=\_root.archerdifficulty) {  
//setting the enemy number  
\_root.archerenemyCounter++;  
//putting the enemy on stage  
\_root.archercurrentEnemy = \_root.attachMovie(“archerenemy”, “archerenemy”+\_root.archerenemyCounter, 500+\_root.archerenemyCounter);  
//putting the enemy in the right place of the stage!  
\_root.archercurrentEnemy.\_y = random(150)+150;  
\_root.archercurrentEnemy.\_x = -100;  
//I think they are too big… resizing  
\_root.archercurrentEnemy.\_xscale = 17;  
\_root.archercurrentEnemy.\_yscale = 17;  
//this line says: “-come back in one second”  
\_root.archerstartTime = \_root.archercurrentTime;  
//setting max dificulty(spawning frequency)

}  
//for each 30 seconds we will clear our index  
if (\_root.archercurrentTime-\_root.archerstartTime\>=30000) {  
//this will make names repeat  
\_root.archerenemyCounter = 0;  
}  
}  
};
