# Array of animations

**URL:** <https://forum.makecode.com/t/array-of-animations/4022>\
**Category:** Help\
**Created:** [October 22, 2020, 7:10pm UTC](https://forum.makecode.com/t/array-of-animations/4022 "2020-10-22T19:10:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 22, 2020, 7:10pm UTC](https://forum.makecode.com/t/array-of-animations/4022/1 "2020-10-22T19:10:26Z")

</div>

Hi there, me again. 😊

Yesterday, I had created an array of animations. For each car sprite, I assign an ‘data variable’ which points to an index within the array. That way when I start the level, I move the cars and assign the animations.  
Today, when I opened the block code, it had changed the array of animations, into a two dimensional array of images.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/49f0d0653100560ec1ed91c156400f0c5081998b.png)  
The variables carAnimationsLeft & carAnimationsRight are no longer an array of animations, but an array of an array of images.

In the next screen shot I fixed the variable _carAnimationsRight_. Both work in the code, but I would prefex to keep the array of animations frames, so that I can of course edit the frames and not the individual images.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/efab8817b7bba8db83da7789e84f7761dab85034.png)

Here is the code:

> **[Frogging Fun 0.9.0](https://arcade.makecode.com/52746-05536-36458-01121)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [October 22, 2020, 7:16pm UTC](https://forum.makecode.com/t/array-of-animations/4022/2 "2020-10-22T19:16:06Z")

</div>

These green animation blocks:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d971a56ff767393366e9c15cbb0a6e779c3c3278.png)  
Are the same as an array of images:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1da86864fafc3c82a76cda6c21d3b120ddd20691.png)

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 22, 2020, 7:23pm UTC](https://forum.makecode.com/t/array-of-animations/4022/3 "2020-10-22T19:23:05Z")

</div>

Thanks for you reply. I realize that an animation is just array of images, however, the moment they become any array of images, I can no longer edit them in animations editor. The animations editor allows you to create multiple frames, and even see the difference between each frame to notice what has changed between each frame.  
Since I store the index of the animation per sprite and know whether it is travelling left/right (speed) I just have to get that value from the array.  
I DO NOT want to have to assign a variable to each animation and then have some gigantic if block. That kind of defeats the purpose of using an array.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [October 22, 2020, 7:29pm UTC](https://forum.makecode.com/t/array-of-animations/4022/4 "2020-10-22T19:29:19Z")

</div>

This should work:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/71dc2d726228e63d934064ef4f368ffa4b94f80e.png)

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [October 22, 2020, 10:07pm UTC](https://forum.makecode.com/t/array-of-animations/4022/5 "2020-10-22T22:07:27Z")

</div>

Did you switch to JavaScript? I don’t think the MakeCode decompiler can handle nested arrays like this; probably a bug.

The decompiler is the part of MakeCode that goes from JavaScript =\> blocks

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 23, 2020, 10:19am UTC](https://forum.makecode.com/t/array-of-animations/4022/6 "2020-10-23T10:19:18Z")

</div>

I think I know what the problem was. Since I was having an issue with downloading the game to the PyGamer, I thought about trying again. So I created a new repo in GitHub, installed all the required extensions, and then copied the entire javascript from the old to the new game. In the old game, the variables were declared as arrays of animations (which of course is Image[][]). I think when pasting the javacript, blocks had no way of knowing what the block element is, and creates whatever it should be. I know that the blocks is one big xml file. I just redefined the arrays again, in block code, and everything is fine again. Here is the latest version:

> **[Frogging Fun 0.9.1](https://arcade.makecode.com/79100-82311-87169-53993)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 23, 2020, 7:04pm UTC](https://forum.makecode.com/t/array-of-animations/4022/7 "2020-10-23T19:04:55Z")

</div>

@richard  
I think this is still an issue. I loaded the GitHub repository into Firefox, where I have never used the editor, and the array of animations turned into array of (array of image). For the same code that I was last using in Chrome, I still see the array of animations.

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 24, 2020, 8:06am UTC](https://forum.makecode.com/t/array-of-animations/4022/8 "2020-10-24T08:06:24Z")

</div>

> [@richard](#):
>
> Did you switch to JavaScript? I don’t think the MakeCode decompiler can handle nested arrays like this; probably a bug.

This is definitely a bug, and a very annoying one. Each time I switch tu Javascript and back to Blocks, then the array of animations becomes an array of images again. Each time it just gets weirder:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f80bd3c5a96ad3f35179b7c0e57ed614ad75ce0e.png)

Can someone please post a bug in GitHub, or redirect me to where I can post it?

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [October 24, 2020, 2:04pm UTC](https://forum.makecode.com/t/array-of-animations/4022/9 "2020-10-24T14:04:49Z")

</div>

I posted an issue here: [https://github.com/microsoft/pxt-arcade/issues/2522](https://github.com/microsoft/pxt-arcade/issues/2522)
