jdf / Processing.py-Bugs

A home for all bugs and feature requests about Python Mode for the Processing Development Environment.
41 stars 8 forks source link

Problem importing proscene library #201

Closed Cegard closed 6 years ago

Cegard commented 6 years ago

Hello people, I'm starting to move a proscene example written in java to python, but when I try to import the library with:

add_library('proscene')

I've got the next error message:

java.lang.NoClassDefFoundError: android/view/MotionEvent at java.lang.Class.getDeclaredMethods0(Native Method)

I've already installed the proscene library.

jdf commented 6 years ago

Thanks for the report.

Yes, it seems I have to be more careful to avoid attempting to import a Java class meant for Android.

As a workaround, until I've addressed this problem, I note that after that exception is thrown, running the sketch again works as expected.

add_library('proscene')

def setup():
  size(640, 360, P3D)
  global scene
  scene = Scene(this)
  # when damping friction = 0 -> spin
  scene.eyeFrame().setDamping(0)

def draw():
  background(0)
  fill(204, 102, 0, 150)
  scene.drawTorusSolenoid()

def keyPressed():
  if(scene.eyeFrame().damping() == 0):
    scene.eyeFrame().setDamping(0.5)
  else:
    scene.eyeFrame().setDamping(0)
  println("Camera damping friction now is " + scene.eyeFrame().damping())
Cegard commented 6 years ago

You were right, in my case I had to run the sketch a few more times to get it to work. Thanks for your help.

jdf commented 6 years ago

Pushed in build 3035.