We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible to work with static fields in my own class in Processing? How to?
Here is an example of what I want to do:
Auto a;
void setup(){
size(400,400);
Auto.ctr=0;
a=new Auto();
}
void draw(){
a.draw();
}
class Auto{
static int ctr;
Auto(){ctr++;}
void draw(){text("Driving",width/2,height/2);}
}
However, I get an error: The field ctr cannot be declared static in an non-static inner type, unless initialized with a constant expression.
So, yes... If I do instead private static int ctr;
then the error goes away but the functionality is lost. Is there a way to do this with a non-constant field at all?
Kf
Answers
Why? you can't write a getter for it? never mind -- I see now what you were trying to do in setup. See GoToLoop below.
=D> Great, thxs. That will do for me.
Kf