Processing Forum
Hi I've been needing to get variables of an object inside a vector,
It doesn't seem to work when you have a period at the end of a vector "get" method
eg. someVector.get(0).x (x cannot be resolved or is not a field)
however if you use an array it works
eg. someArray[0].x
the"someVector.get(0)" does return the object, but i just can't get into the object's
variables.
Is there a way to use Vectors and get variables of objects inside the vector?
I saw that it works with Java here:
http://stackoverflow.com/questions/3909517/accessing-variables-of-objects-stored-within-a-vectorbut I'm not sure if it's the same with processing.
example code (Working with array)
class Turtle
{
float x;
float y;
Turtle (float _x, float _y)
{
x = _x;
y = _y;
}
}
turtles[0] = new Turtle(1,2);
println (turtles[0].x); //prints 1