# Sprite Array

**URL:** <https://forum.makecode.com/t/sprite-array/445>\
**Category:** Arcade\
**Created:** [August 14, 2019, 5:17pm UTC](https://forum.makecode.com/t/sprite-array/445 "2019-08-14T17:17:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vidget](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vidget/32/29_2.png) [@Vidget](https://forum.makecode.com/u/Vidget)\
**Post date:** [August 14, 2019, 5:17pm UTC](https://forum.makecode.com/t/sprite-array/445/1 "2019-08-14T17:17:27Z")

</div>

Not sure if I’m doing this right? Trying to create an array of sprites. But when I do all of the sprites in the array are displayed on the screen at once. Calling a specific index doesn’t do anything.

> **[Sprite Array](https://arcade.makecode.com/98306-64231-08444-12313)**
>
> Made with ❤️ in MakeCode Arcade.

 ![issue](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/c1f0cc0cf8b1ea5d75f317ce75097e16d2ece2f7.jpeg)

---

<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:** [August 14, 2019, 5:25pm UTC](https://forum.makecode.com/t/sprite-array/445/2 "2019-08-14T17:25:55Z")

</div>

Sprites appear on the screen when they are created, as creating them adds them to the game engine. In this case, you’re creating three sprites, and storing references to them in an array; if you added `set {sprite list get value at 1} position to x {0} y {0}` it will move the apple to the top left corner, and if you add `move {sprite list get value at 2} with buttons` you will be able to move the lemon around the screen with the buttons.

The `array of sprites of kind food` returns an array with all the existing sprites of kind food – in this case the array will be empty, because at the time you are calling it non have been created yet.

What are you trying to use this for / what’s the end goal? You might want to use an array of `Images` instead if you just want to be able to create three different types of food sprites.

---

<div class="post-metadata">

**Author:** ![Vidget](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vidget/32/29_2.png) [@Vidget](https://forum.makecode.com/u/Vidget)\
**Post date:** [August 14, 2019, 5:37pm UTC](https://forum.makecode.com/t/sprite-array/445/3 "2019-08-14T17:37:01Z")

</div>

I have about 20 images that I want to access randomly

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [August 14, 2019, 5:42pm UTC](https://forum.makecode.com/t/sprite-array/445/4 "2019-08-14T17:42:15Z")

</div>

[https://makecode.com/\_9MXDJ7gxR1bH](https://makecode.com/_9MXDJ7gxR1bH) Maybe like this.

 ![46%20AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/d2cf916b9884950065a9917d0bb4679310046803.png)

---

<div class="post-metadata">

**Author:** ![Vidget](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vidget/32/29_2.png) [@Vidget](https://forum.makecode.com/u/Vidget)\
**Post date:** [August 14, 2019, 5:44pm UTC](https://forum.makecode.com/t/sprite-array/445/5 "2019-08-14T17:44:04Z")

</div>

Thanks, I think I can make this work for what I want. AWESOME!

---

<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:** [August 14, 2019, 5:59pm UTC](https://forum.makecode.com/t/sprite-array/445/6 "2019-08-14T17:59:53Z")

</div>

And small add on to @jedgarpark’s example, if you want random images, here’s one way to do it:

> **[image array](https://arcade.makecode.com/01388-57406-16411-17483)**
>
> Made with ❤️ in MakeCode Arcade.
