How to directly use the class from library in my class

//First label

add_library('box2d_processing')
add_library('jbox2d')

from gameInterface import GameInterface

def setup():
    global gameI
    box2D =Box2DProcessing(this)
    gameI=GameInterface(box2D)
//Second label
class GameInterface:
    def __init__(self,b):
        self.box2d=b
        
class rectBoundary:
    bd=BodyDef()

If I initialize the BodyDef() in the setup() and deliver it through the init(),
it can work.
But compared to java. Why can’t I directly use the class from library in the class which created by myself?
:smiling_face_with_tear: :thinking:

Add a (Python) import line for JBox2D to your gameInterface.py file –

from org.jbox2d.dynamics import *

class GameInterface:
    def __init__(self,b):
        self.box2d=b
        
class rectBoundary:
    bd=BodyDef()
2 Likes

Wow! It works. Thanks a lot. Could you tell me the reason, the difference between add_library and import. Could you give me a brief explanation or some source about it. Sincerely appreciate!

1 Like