Sprites across different tilemaps

I’m not a coder, so I need lots of help to be able to help my students. They are developing a three-level game. They use “on sprite overlaps this tile, set new tilemap” to go to the next level. The problem is that projectiles from previous tilemaps keep spawning and new projectiles don’t spawn.

Please provide a share link of this particular game here so it is possible for a forum member to help.

Thanks! Here is a mock up:

I understand that the donuts keep appearing because they are in a forever loop but I don’t know how to stop it. I also understand that the hamburger appears only once, on overlap, and would need to be in some kind of forever loop.
In both cases, the question is, how do I code “forever while on this tilemap.” I have tried different if, thens, but with no success.
Thank you so so much for helping out a teacher!

3 Likes

You can use a level variable to control which sprites spawn, and when they spawn.


I hope this helps! :slight_smile:

1 Like

I did not figure out how to compare the image of the current tilemap directly, but one way is to set a state variable for each tilmap and check this for setting the correct projectile in the loop:

Remove all sprites from current tilemap when entering the new tilemap by using e.g. the sprites.destroyAllSpritesOfKind(SpriteKind.Projectile) block.

Hahaha, @Blobbey!

You beat me by just one small minute with almost exactly the same solution!
(But we are talking @MakeCode moderator approval timestamps, so not sure if you really were first…) :wink:

Anyhow, this is not a competition.

Does anyone know how to do stuff like this without using state variables?

I am tired of fighting with/keeping track of state variables all over the place all the time…

1 Like