user9229318
user9229318

Reputation:

p5.js How to delete the last draw()

I'm not quite sure how to word this. I've been messing around with p5, and always come across this "error".

function setup(){
    createCanvas(400,400);
}

function draw(){
    textSize(32);
    text(second(), 10, 30);
}

All I'm trying to do is display the second. However, what happens is that it displays the second e.g 50, and then when second == 51, it simply writes over the 50. What I would prefer to happy is for the browser to display 50, delete 50, display 51, delete 51... The image below represents what is being displayed.

over-writing

Upvotes: 1

Views: 1676

Answers (1)

EricLavault
EricLavault

Reputation: 16035

In your draw function, just draw/redraw the background as well :

function draw () {
  background(90, 90, 90);
  textSize(32);
  text(second(), 10, 30);
}

Upvotes: 1

Related Questions