Whts wrong with this
game = {};
game.Enemy1 = 10;
function initEnemies()
{
for (i=0; i<game.Enemy1; ++i)
{
attachMovie("enemy1", "firstEnemy "+i, i)
firstEnemy = _root["firstEnemy "+i];
trace(firstEnemy);
updateEnemy1(firstEnemy);
firstEnemy.onEnterFrame = function ()
{
if (this.hitTest(bullets)) //checks collison with bullets
{
score += 10;
trace(score);
bulletActive = false;
removeMovieClip(bullets);
updateEnemy1(this);
}
if (this._x>0) //checks if enemies are on the screen
{
this._y += this.velocity; //move the enemy down
}
else
{
updateEnemy1(this);//creates new enemies
}
};
}
}
initEnemies();
function updateEnemy1(which)
{
which.gotoAndStop(random(10));
which._x = random(500)+10;
which._y = random(80)+10;
which.velocity = random(8)+2;
}
Movieclip name : Enemy1
This is the code from vertical shooter tut which iam using for a similar shooter game, if i use this the enemy set is generated only once in the screen, after the enemies dissapear, the updateEnemy1() function does not recreate the enemies on the screen again.
What is wrong with my code.