# Replacing tiles in tilemap with animated sprites

**URL:** <https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218>\
**Category:** Arcade\
**Created:** [December 24, 2020, 9:54pm UTC](https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218 "2020-12-24T21:54:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tncbbthositg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tncbbthositg/32/2288_2.png) [@tncbbthositg](https://forum.makecode.com/u/tncbbthositg)\
**Post date:** [December 24, 2020, 9:54pm UTC](https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218/1 "2020-12-24T21:54:09Z")

</div>

I’d like to be able to animate a few parts of my background. I’d like to have a tile in the tilemap that I could replace with sprites that have animations attached.

That seems to work OK, but the tile still shows up under the sprite. How can I remove the tile and replace it with the sprite instead?

Thanks!!

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [December 24, 2020, 9:58pm UTC](https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218/2 "2020-12-24T21:58:25Z")

</div>

If you already have the code to place sprites on top of each of the tiles (something along the lines of ‘for each (image) tile place sprite’), you’ll just want to clear the tiles image with this:

 ![SmartSelect_20201224-135738_Chrome](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/09386fe69974bae230c751451e424008ad4e6ade.jpeg)

---

<div class="post-metadata">

**Author:** ![tncbbthositg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tncbbthositg/32/2288_2.png) [@tncbbthositg](https://forum.makecode.com/u/tncbbthositg)\
**Post date:** [December 24, 2020, 10:47pm UTC](https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218/3 "2020-12-24T22:47:16Z")

</div>

Oh, clever! Thanks. I assume it’ll accept the value from iterating an array of sprites.

Thanks again! Happy holidays! 🙂

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [December 24, 2020, 10:49pm UTC](https://forum.makecode.com/t/replacing-tiles-in-tilemap-with-animated-sprites/5218/4 "2020-12-24T22:49:00Z")

</div>

Ah, it takes the tile locations you get from the array of all tiles rather than sprites, but I think that’s what you meant (since you would likely have to be using that to get the animating sprites created in the first place!)

And happy holidays to you too!
