First of all, I must say you have created a more advanced game out of 2 newbie questions and you're about to produce a complete product ))
I am checking your sample without JSON, because I am not familiar with JSON at all, yet.
At start of layout:
You set a 2 dimensional array with SpriteCount ,2 (SpriteCount array)
And you create another array (0,1,1) (ArrayPosition) so, initially this array has 0 size.
You go through all the instances of the Sprite, you set the values stored in the array's 1st column, to X values of the sprites, and you set the values stored in 2nd column of the array to the Y values of the sprites.
I can understand that you are triggering the "Set" method (or function) when the Sprite.Count is 0. This happens both when the user clicks and destroys all boxes, and also is triggered at start of the layout because there is "Sprite Destroy" item at start.
I am trying to figure out the "set" function,
A local variable named Rnd is created and set to 0, OK.
A for loop is created, it will use "frame" variable from 0 to ArrayPosition.Width-1 which is 1 less than the sprite count, OK. It will be looped for Sprite.Count times as it starts from 0.
"Push back loopindex on X axis" -> you insert loopindex value to the ArrayFrames array, and I guess since you are pushing to X axis, it should be like (0,1,1) where 0 is X. That would populate the ArrayFrames's X address with 0,1,2,3...15 for 16 sprites.
WHen we come to ForEach statement, we create a random integer between1-15 (width of ArrayFrames) and then Create a sprite at positions related to ArrayPosition.At(ArrayPosition.CurX,0), ArrayPosition.At(ArrayPosition.Curx,1) I just couldn't get where this part can get the actual position information instead of just 0,1,2,3...
After creating the sprites, the animation frame of each sprite is taken from the randomth element of ArrayFrames array. This is a very clear and clever approach, IMO.
I have 2 things that I couldn't understand completely:
1. How do you prevent repetitive numbers to take place? I couldn't get that part of the logic in the event sheet.
2. How is the actual coordinates set? (ArrayPosition.CurX stuff)
You've already done more than I would expect, so it is still OK if you wouldn't like to explain further