level 6



String msg = "这是一条很长很长的信息,长到超过了一个屏幕,真的很长很长";String txt;
PFont font;
float x1, x2;
void setup(){
size(320,64);
smooth();
font = createFont("宋体", 16, true);
//制备超过一屏的字符串
txt = msg;
while(textWidth(txt) < width){
txt += " " + msg;
}
x1 = 0;
x2 = 0;
}
void draw(){
background(0,0,0);
fill(0,255,0);
textFont(font, 16);
text(txt, x1, height/2);
if(x1 + textWidth(txt) < width){ //第一条信息不足一屏,第二条信息进入
x2 = x1 + textWidth(txt) + 32;
text(txt, x2, height/2);
if(x1 + textWidth(txt) < 0){ //第一条信息完全走出屏幕,那么第二条就是第一条
x1 = x2;
}
}
x1 -= 1; //移动
}
==========================
当然实现的方法很多,比如可以用循环链表什么的


