PApplet being re-instantiated - how to get Data into the PApplet
in
Programming Questions
•
7 months ago
Hi everyone!
I'm almost sure this has been asked before, but I could not find it. :-(
I want to do this: I have a class A that extends PApplet that I want to show. To show something meaningful, I have to pass some data to A, I currently do this in the constructor. But, when I run A.init(), A seems to be re-instantiated (i.e. the empty constructor is being called), and of course none of the data I passed in earlier is there.
My second try was to make the draw() method in A empty, and have a setData(...) and drawStuff() method (which holds what was in draw() ), which I would call like this:
A a = new A();
a.init(); // At this point, A is re-instantiated
a.setData(...);
a.drawStuff();
But this does not show anything - I guess an empty draw() method is not good?
It would be absolutely awesome if someone could point me in the right direction here. Thanks a lot!
I'm almost sure this has been asked before, but I could not find it. :-(
I want to do this: I have a class A that extends PApplet that I want to show. To show something meaningful, I have to pass some data to A, I currently do this in the constructor. But, when I run A.init(), A seems to be re-instantiated (i.e. the empty constructor is being called), and of course none of the data I passed in earlier is there.
My second try was to make the draw() method in A empty, and have a setData(...) and drawStuff() method (which holds what was in draw() ), which I would call like this:
A a = new A();
a.init(); // At this point, A is re-instantiated
a.setData(...);
a.drawStuff();
But this does not show anything - I guess an empty draw() method is not good?
It would be absolutely awesome if someone could point me in the right direction here. Thanks a lot!
1