We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I would like to use the gif library out of a class that I have written. If I write something like:
Gif myAnimation = new Gif(this, myFile);
...Processing gives an error as it references to my class and not my main App. How do I reference to main sketch? I am pretty sure it has something to do with PApplet, but I can not get it working! Thank you!
Answers
pass the papplet into your class via the constructor... use that in the Gif constructor call.
see the Processing in Eclipse with Multiple Classes bit of this:
https://processing.org/tutorials/eclipse/
Hi koogs! Thank you! I really have to learn how classes work in processing! Just as a fast workaround that I am sure is not the best way I just found this in another threat "sketchname".this. I shouldn't change the name of my sketch now, right!? :)
Java's keyword
this
is always of the datatype of theclass
block it was typed in.Let's say your
class
is called MyGif:That won't compile b/c Gif's constructor demands that its 1st parameter to be of datatype PApplet.
But that
this
is of datatype MyGif instead. #-oThere are many approaches to workaround it. And you've already found out 1 as
SketchName.this
. :ar!But the simplest 1 is to instantiate such libraries in the main sketch; and then pass it as an argument for the target
class
: *-:)