# How do i make it so enemies stop spawning after tilemap has changed

**URL:** <https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390>\
**Category:** Help\
**Tags:** game\
**Created:** [April 23, 2024, 1:40pm UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390 "2024-04-23T13:40:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![james-jamerson](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@james-jamerson](https://forum.makecode.com/u/james-jamerson)\
**Post date:** [April 23, 2024, 1:40pm UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390/1 "2024-04-23T13:40:07Z")

</div>

how do i make it so enemies stop spawning after tilemap has changed, i am trying to make a dungeon type game but when i clear the first floor the enemies keep spawning

---

<div class="post-metadata">

**Author:** ![Brainstorm\_Studios](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brainstorm_studios/32/20476_2.png) [@Brainstorm\_Studios](https://forum.makecode.com/u/Brainstorm_Studios)\
**Post date:** [April 23, 2024, 6:22pm UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390/2 "2024-04-23T18:22:05Z")

</div>

on tilemap unloaded {tilemap} do

destroy all sprites of kind [enemy]  
destroy all sprites of kind [enemy2]

(rinse and repeat for however many enemies are in your game)

call function [enemies]  
call function [ranged\_enemies]

(call all the functions that spawn the enemies)

---

<div class="post-metadata">

**Author:** ![CopySprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/copysprite/32/35475_2.png) [@CopySprite](https://forum.makecode.com/u/CopySprite)\
**Post date:** [April 23, 2024, 6:22pm UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390/3 "2024-04-23T18:22:14Z")

</div>

Welcome to the comunity @james-jamerson there are two ways I can help.  
1.If you post your code I can fix it.  
2.you could use a variable and set it to true when enemy’s spawn and false when they don’t.  
Kind of like this. 🔻  
 ![Screenshot 2024-04-23 10.36.23 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a121c0a98a63aebcdff927a0bfb9ddf374ce1b95.png)  
I hope this is helpful.

---

<div class="post-metadata">

**Author:** ![james-jamerson](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@james-jamerson](https://forum.makecode.com/u/james-jamerson)\
**Post date:** [April 29, 2024, 4:03pm UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390/4 "2024-04-29T16:03:56Z")

</div>

i dont know how to give code but i found how to copy the link to the game if it helps: [https://arcade.makecode.com/S23723-90059-15759-77657](https://arcade.makecode.com/S23723-90059-15759-77657)

---

<div class="post-metadata">

**Author:** ![CopySprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/copysprite/32/35475_2.png) [@CopySprite](https://forum.makecode.com/u/CopySprite)\
**Post date:** [April 30, 2024, 4:06am UTC](https://forum.makecode.com/t/how-do-i-make-it-so-enemies-stop-spawning-after-tilemap-has-changed/28390/5 "2024-04-30T04:06:04Z")

</div>

It helps but where do you want the enemy’s to stop spawning?
