always keep set number of (spawned) actors on scene

Hello everyone. First I'd like to thank you all for making this forum such a great place to learn GS.
I have this little game where 30 enemies are spawned in every scene and the hero shoots at them. I'd like to have 10 actors on the scene each moment, otherwise the scene will be too crowded. When the hero shoots one enemy, another will be spawned (until there will be spawned 30 in total). So my question is how do I keep the enemies to 10 each moment ? Thank you for any ideas!

Answers

  • CasualEvolutionCasualEvolution Member Posts: 529

    Use a global variable to count the enemies on screen: whenever an enemy dies subtract 1 and every time one is born add 1
    In another variable, consider total of enemies who are born, adding 1 every time there is a new one.
    Then just let spawn a new enemy only if enemys on screen are less than 10 and the total are under 30.

  • mac(manousmac(manous Member Posts: 2

    Thank you very much for your answer. I will try it tomorrow and let you know.

Sign In or Register to comment.