0
var j=0;
function keyPressed() {
word[j] =key;
j++;
if(keyCode == BACKSPACE){
shorten(word);
shorten(word);
arrayCopy(word, contents);
}
else{
contents=key;
}
}
function draw(){
text(contents, pos_x, pos_y, 300, 300);
pos_x = pos_x + textWidth(contents);
}
当我使用退格键时,我使用shorten()删除array.how的最后一个元素,将此新文本放在画布上,而不调用clear()和背景()。如何清除p5js画布上的旧文本
请发表[mcve]。为什么你不想使用'background()'函数?这通常就是你如何处理这个问题。 –
当我们使用background()函数时,画布上的其他绘图消失,重新绘制绘图,如果我们尝试createGraphics()函数,关闭屏幕图形缓冲区,将出现性能问题。请尝试使用最佳解决方案。 – Tanzeem