Hi JonathanFeinberg, it's an honor to talk to you, and thank you for making python mode!
I'm using Processing 3.3.6 with python mode of 3035, and the code below returns error that is, 'Vec2' is not defined.
Seems like add_library() can only import the library whose ".jar" filename matches its string argument.
However, libraries such as "fisica", "box2d_processing" & "LiquidFunProcessing" have an extra ".jar" file there too.
And that additional ".jar" file is the library "jbox2d".
Which btW, got the class Vec2 which you are struggling to use in your sketch.
Unless we can pass the whole path to add_library(), Python Mode can't reach that helper library.
But don't fret! I've found out a workaround for it:
Manually make "jbox2d" globally available as a 3rd-party library on its own.
Just go to the sketch's subfolder "libraries/" where all 3rd-party libraries are installed.
Create a folder there named "jbox2d". And inside that, another folder called "library".
Pick n1 of those "jbox2d.jar" files from "fisica", "box2d_processing" or "LiquidFunProcessing", and copy it into your new "jbox2d/library/" folder.
Rename that ".jar" file exactly as "jbox2d.jar". So it matches its parent folder "jbox2d".
Now you can finally import it into your sketch like this: add_library('jbox2d').
add_library('box2d_processing')
add_library('jbox2d')
def setup():
size(500, 400)
global box2d, center
box2d = Box2DProcessing(this)
center = Vec2(width>>1, height>>1)
box2d.createWorld(center)
print center
exit()
Answers
Could you please post a small but complete example that doesn't work as you'd expect it to?
Hi JonathanFeinberg, it's an honor to talk to you, and thank you for making python mode! I'm using Processing 3.3.6 with python mode of 3035, and the code below returns error that is, 'Vec2' is not defined.
add_library('box2d_processing')
https://Forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
add_library('jbox2d')
.