How to count the amount of a certain sprite there are?

I was wondering if it was possible to count the amount of a certain sprite there are that are currently existing. This would be very useful for me since I’m making a game that has waves and I don’t want to have the player wait for the next round of enemies to come if they kill them to fast.

Do you mean you want to know how many sprites of a particular kind exist? Like … how many Enemy sprites exist?

If so, you can do this:

If all sprites that are enemies share the same SpriteKind, use

sprites.allOfKind(SpriteKind.[InsertSpriteKind]).length

to get how many there are currently present.
Note: This was scripted through MakeCode’s JavaScript.

1 Like

wait do I have to like put the sprites in the list? Because my coding instincts are telling me yes

You don’t have to do that manually, no, as long as you’re counting sprites of a particular kind. The blue block in my code creates the list for you.