[libGDX] libGDX Array object

Hello everybody, I think I need some coaching with the handling of the libGDX Array. I play around for more understanding with the pathTest. Its a class which demonstrate how to use splines with libGDX. (by XOPPA)
Among other things there is an array like this:


Array<Path<Vector2>> paths = new Array<Path<Vector2>>();
paths.add(new Bezier<Vector2>(new Vector2(0,0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));

For my part it could be also in this way:

 
Array<Vector2> vec = new Array<Vector>();
vec.add(new Vector2(110,110));

The first one is an array of a bezier pathes, the second one an array of vectors. The question is how can I reach and manipulate the values of the inner elements. Do I have to create everytime a complete new Vector2 object like this:

 vec.set(0, new Vector2(120f,120f);

or how can I manipulate only one value from the vector? Same question for the first construct above with the path array. How can I manipulate only one value from the path element in the array?

Sorry for cumbersome explanation…and thank you for your helpfulness

Haven’t played with paths, but you could access an object in the array by using array.get(int index). Once you have the object, explore any fields or getters/setters it provides to manipulate it. I know Vector2 objects give you access to x and y fields.

e.g.

vec.get(0).x = 15

Hope that helps.

There is a [icode]get()[/icode] method in the [icode]Array[/icode] class. This should change it.


vec.get(0).set(110, 110);

Or you can directly access the field [icode]items[/icode] which does the same thing.


vec.items[0].set(110, 110);

Hope this helps.

Thank you at both of you. With the vector array its all oK now. Thank you. I think the path object couldn´t be manipulated in its vectorpoints later.