Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Fisica and Integration with Navigation Drawer

$
0
0

Hi, first of all, I want to share my excitement as I only realized today that PApplet was now extending Fragment rather than Activity :D

Second, I am now playing with this new PApplet and trying to place it as part of a NavigationDrawer kind of application.

However, it results in this error when switching away from the PApplet:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.app.Activity.getSystemService(java.lang.String)' on a null object reference
at processing.core.PGraphicsAndroid2D.imageImpl(Unknown Source)
at processing.core.PGraphics.image(Unknown Source)
at fisica.FDrawable.drawImage(FDrawable.java:97)
at fisica.FCircle.draw(FCircle.java:101)
at fisica.FDrawable.draw(FDrawable.java:119)
at fisica.FBody.draw(FBody.java:41)
at net.diyoyo.MainSketch.draw(MainSketch.java:76)
...

in my PApplet, I just attach an image to a body:

in setup():

    inner=loadImage("inner.png");
    circle1=new FCircle(inner.width);
    circle1.setPosition(width/2, height/2);
    circle1.setName("inner");
    circle1.attachImage(inner);
    //circle1.setStatic(true);
    circle1.setSensor(true);

in draw():

    background(255);
    world.step();
   // image(inner, displayWidth/2, displayHeight/2);
    circle1.draw(this);

This last line causes the error.

I am using Fisica directly from the source, but I don't understand what's wrong in the drawImage method:

protected void drawImage(PGraphics applet) {
applet.tint(255, 255, 255, m_imageAlpha);
applet.image(m_image, 0-m_image.width/2, 0-m_image.height/2);
applet.tint(255, 255, 255, 255);
}

I tried changing draw(this) by draw(this.g), but it does do anything...

I guess it's a problem of how PApplet now manages the images when it is sent to the back stack or something, isn't it?

Thanks.


Viewing all articles
Browse latest Browse all 941

Trending Articles