A generic answer... You need to clear screen by calling
background(colorWanted) at beginning of draw whenever you want the screen cleared. Or draw a rect() filled with the color of background over the text to "erase" only that area.
It's very common to call background() at the beginning of every draw() cicle, (let's say a frame), so things are constantly redraw. Then you can just erase the string containing the text and/or replace it...
below, frameCount is a string (converted by text()) constantly being replaced...
Edit: actually I'm not sure if is text() that makes the conversion...
- void draw(){
- //comment out next line to see..
- background(255);
- fill(0);
- text(frameCount, 10, height/2);
- }