Hello,
In my project, I’m creating enemies with the function enemy.new. Something like this;
enemyspawntimer = timer.performWithDelay(600, function() Enemy.new() end, 0)
And those enemies gets destroyed by different stuff during gameplay. But I also want to have a function called removeEnemies() which removes all the enemies. This is the part I’m having problem with. I was thinking about creating a table allEnemies = {} , and adding each enemy as a child as the enemies created, and than loop over it to remove each of them. This kind of doesn’t work because when destroying an enemy with a random event, I can’t remove it from the allEnemies table because I don’t know where it is in that table. So my removeEnemies() function tries to remove enemies that already got removed. (This doesn’t give an error, but, since I’m using #allEnemies, the loop count is always going up even tho there are only a few enemies remaining on-screen)
I hope I could express my situation, all help is appreciated!