We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I code something in Java Mode using Eclipse.
I have a Processing class
public class Pikachu extends PApplet
and an ordinary Java class
public class Jojo
They're in separated file, because it's too complicated and messy to put them in one file.
And, the public static void main
is with Jojo.
I wanna call Pikachu using Jojo, and also add some params, but I'm confused on how to do that.
Let's say Pikachu is just ordinary Java class like Jojo.
Then, when I wanna run/call Pikachu from Jojo, I just need to make the object, like,
Pikachu pika = new Pikachu(param1, param2);
How to do this with Processing class?
I tried some things, but just lead me to error (like calling it like usual Java class, or even make constructor...)
If I have a mistake, or there's any lack information, or you have a link that may help me, I will be really glad if you'd like to tell me.
Some details:
Machine: Win8 x64
Processing: 2.1.2
Eclipse: Eclipse IDE for Java Developers
Answers
"I tried some things, but just lead me to error"
Might be interesting to see the attempts, and the error messages...
Processing in short is a framework API which runs under a Thread called "Animation Thread".
A PApplet's instance has a JFrame window + a PGraphics canvas too!
I believe it'd be much easier if you have a separate Overseer class, which implements PApplet, for your other classes!
Here's an initial template for it:
You just need to pass the Overseer instance reference to any class which wants to interact w/ Processing's canvas!
P.S.: I don't use Eclipse! @_@
@PhiLho
Thank you very much for your reply! :)
Well I've said it...
Buuut dafuq me ( ._.) when I tried this, it worked...
and when I called it in Jojo, it works
Instantly, Pikachu is executed just like usual Processing.
@GoToLoop
Thank you very much for your reply! :)
Sorry, so sorry I'm so newbie ( T_T) I'm afraid I don't understand this part:
I'm very interested with that implementation, because it seems tidier and can control both class... What if the params I wanna pass is something produced by Jojo? How to do that?
Ah, don't worry about Eclipse. I use IDE so that I don't have to blahblahblah the libs when compiling and running, and since I use many components I just have known, it would immediately tell me when I type something irrelevant.
"when I tried this, it worked"
That's why I asked, I didn't see problems with the process you described, hence my question... :-)
Wait wait now I understand GoToLoop answers... Thank you very much!
@PhilHo Hoo I see I see! Thank you very much! :D
Just as an addendum, some class templates for Jojo & Pikachu!
That's in case they need to access Processing's API & each other of course! *-:)