Sam, I'm not quite sure what the problem is. You do have access to all methods and variables of the main class directly from all other classes you define. If you need one object to be able to access the data of another object the "nicest" way is to pass it as a parameter to a function, i.e.:
Code:class Obj1 {
float x,y;
}
class Obj2 {
float x,y;
void addPosition(Obj1 o) {
x+=o.x;
y+=o.y;
}
}
If the classes really function as a parent-child hierarchy the best solution would be to use a parent reference variable and passing that to the child object as part of the constructor.
Code:class Parent {
float x,y;
}
class Child {
Parent parent;
float x,y;
public Child(Parent theParent) {
parent=theParent;
x=parent.x;
y=parent.y;
}
}
Mythmon's sketch is right, but the correct way to describe it would be to say that a local class has access to all data of the class it is defined in. In Processing, any class you define is actually a local class of the class that is your sketch, which again extends processing.core.PApplet. Most of the time you don't need to know that, though.