I need to transfer for loop to recrusion function..
This is my fucntion:
public void AddEnemyToScreen(int enemy_count)
{
for(int i=0 ; i<enemy_count;i++)
{
AddEnemey(new Enemy(r.nextInt(640), -10, textures,this,game));
}
}
I have tried to do this:
public void AddEnemyToScreen(int enemy_count)
{
if ( enemy_count == 1)
AddEnemey(new Enemy(r.nextInt(640), -10, textures,this,game));
else
{
AddEnemyToScreen(--enemy_count);
}
}
but in some reason it dosent works..