Array of animations

Hi there, me again. :blush:

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.


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.

Here is the code:

2 Likes

These green animation blocks:
image
Are the same as an array of images:
image

1 Like

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.

2 Likes

This should work:
image

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

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:

2 Likes

@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.

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:

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

1 Like

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

1 Like