[Solved] How to randomly select an enemy?

I want to make a game similar to the NES game Galaga. I want to let two random enemies attack, and they are not of the same type of enemy, for example, one is in the front row and the other is in the back row. But now I don’t know how to activate them. How can I select them and make them active? And this process is preferably automatically completed, and I don’t need to set it again in the new level. In addition, it would be best if they could run according to certain rules (such as the one in the back row will move out later).

You could use a sprite that’s stretched across the whole screen and 1 pixel in height. Then place it where the top row of invaders are placed, check for collision and select a random. Something along the line of:


  • TestLine is a pixel high and screen wide sprite
  • InvaderGroup is an object group with all the invaders in it.

Very novel idea, I will try when I go home, thank you.

is work, Thank you! :smile: :smile: :smile: :smile: :smile: :smile: