Hi, I have problems clearing a PGraphics layer. Using Java mode, it works perfect, no more with Android mode. I've tried clear(), background(0,0), none works... The only way I found is to recreate the layer... Why is that?
My code, trimmed down to this problem, is like:
PGraphics layer;
//only debug version works
boolean debug=true;
void setup() {
size(800, 800);
layer=createGraphics(width, height);
layer.beginDraw();
layer.background(0, 0);
layer.endDraw();
}
void draw() {
background(128);
layer.beginDraw();
layer.ellipse(mouseX, mouseY, 50, 50);
layer.endDraw();
image(layer, 0, 0);
}
void mousePressed() {
if (debug) {
layer=createGraphics(width, height);
layer.beginDraw();
layer.background(0, 0);
layer.endDraw();
} else {
layer.beginDraw();
layer.clear();
layer.endDraw();
}
}
Thanks for your answer.