Placing and Removing Sprites on Specific Tiles

Here’s the game code:

I’m using this code to place specific sprites on specific tiles in the function the builds Level 3:

I’m using this code to destroy the previous level’s sprites and set up Level 4:

The problem is that the sprites I need destroyed are staying on the screen when Level 4 starts.

Can anyone tell me why this is happening, or suggest how I can fix it?


Because you’re creating the enemies in a loop, the variables are getting reassigned to always point to the last instance of each enemy being created. Your code will only destroy the last enemy created by each of those loops.

I think you might have more luck if you use the “destroy all sprites of kind” block in the sprites category instead of trying to destroy the variables:

Screen Shot 2022-04-21 at 9.56.16 AM


Thanks! That seems to have fixed the problem!