Errr you are overcomplicating things imo.
First thing first, Xeed you got it wrong considering the use of the array object.
Instead of having some system loops, you have an event within the array object to help you browse through it. (Array:For each element)
There you determine if you want to go through the X coordinates, the XY or the XYZ.
That means that some loops will be automaticly done (cycling through the coordinates) and the action you set will apply to the "cell" at said-coordinates.
For example I have a 10X10 array, I want to fill each cell with a value I'll do:
System:On startup of layout
..Array:For each element XY
.....Action - Array Set at XY
This action has 3 Fields : The X coordinate, the Y coordinate and the Value.
X and Y can be obtained with the system expression Array.CurX and/or Array.CurY (Where Array is the name you gave your array object).
Then you set Value as you like.
Instance Variables apply for the whole object. In your example, you modify the values of your variables posX and posY for the size of your array, but in the end, you only have a single value for each variable.
In fact, in your case, I guess that you would like something like :
X in Array represents an instance of sprite Ground
Y in Array will hold "posX" and "posY" (so respectively Y=0 and Y=1)
This mean that in array coordinates : 0,0 will be instance 0, posX for what you're willing to achieve. 0,1 will be instance 0, posY. 1,0 will be instance 0, posX, etc...
First thing to do in the startup is to set up the size of your array.
Action Array:Set size. Three fields again Width (X), Height (Y) and Depth (Z).
In our case, Width will be the final number of Ground instances that you will deal with (if instances are already created you can access it thanks to Ground.Count), Height will be 2 (posX, posY in your logic).
Then, you will have a "For each Ground" loop in which 2 actions Array.Set at XY will be used.
First one: X is Loopindex, Y is 0, Value is Ground.X
Second : X is Loopindex, Y is 1, Value is Ground.Y
And there you have it. Your array will be filled with the X and Y positions of each Ground sprite instance.
To access it : Array.At(X,Y)
If I want the position X of my 9th instance : Array.At(9,0) (9 is the 9th instance, 0 is X).
If I want the position Y of my 52th instance : Array.At(52,1)
There you got a "proper" use of the array object.
Take the time to get used to it, it's really tricky at first.
But in the end, I'm still not convinced that what you need is an array. As you didn't explained yet clearly what you are trying to do, I answer hit by hit to your questions but I think you're overdoing at some point.
I'm thinking that you are trying to compare a character's sprite coordinates with the Ground coordinates, to know where it is.
You could achieve this by checking which ground instance is the character overlaping, and you would then have direct access to the X and Y coordinates of ground without having to store them in an array.
But yet, as I don't know if that's what you want to do, maybe I'm missing the point there.
Anyway, hope to have helped about the array.
New to Construct ? Where to start Please attach a capx to any help request or bug report !