1
我是新来处理,但我基本上是试图获得这种效果:添加点每秒
等待。
(1秒后)
等待..
(1秒后)
等待...
(1秒后)
等待... 。
(然后重置)
等待。
作为文本();
任何想法,我将能够实现这一点?
我是新来处理,但我基本上是试图获得这种效果:添加点每秒
等待。
(1秒后)
等待..
(1秒后)
等待...
(1秒后)
等待... 。
(然后重置)
等待。
作为文本();
任何想法,我将能够实现这一点?
使用millis()代替它计算自程序启动以来的时间(以毫秒为单位)。这里一个简单的反例:
再次编辑的代码,一个更好的例子
PFont font;
String time = "000";
int initialTime;
int interval = 1000;
int fontSize;
void setup()
{
size(300, 300);
fontSize = 40;
font = createFont("Arial", fontSize);
background(255);
fill(0);
smooth();
noStroke();
textFont(font);
initialTime = millis();
}
void draw()
{
background(255);
// if current time minus lastStored bigger than interval
if (millis() - initialTime > interval){
// increment time as an int and back to string again
time = nf(int(time) + 1, 3);
// reset counter
initialTime = millis();
}
// just cosmetic using the counter ...
if (int(time) % 5 != 0) {
fill(210);
}else{
fill(170, 100, 100);
}
ellipse(width/2, height/2, 120, 120);
fill(255);
ellipse(width/2, height/2, 100, 100);
//display time
fill(0);
text(time, width/2 - textWidth(time)/2, height/2 + fontSize/2.8);
}
嗯,我想我可以用“第二()”,它使用计算机的时钟。并用它做一个循环,但是..秒不会从0开始,而只会上升到3 –