Processing 移动带有平移和时间延迟的rect?
我有这个密码。在每次打印之前,需要将一个rect打印10次,每次向右移动60个图片,延迟1000毫秒。没有,我也不明白为什么。有人能给我解释一下吗Processing 移动带有平移和时间延迟的rect?,processing,Processing,我有这个密码。在每次打印之前,需要将一个rect打印10次,每次向右移动60个图片,延迟1000毫秒。没有,我也不明白为什么。有人能给我解释一下吗 int time; int wait =1000; void setup() { time = millis(); size(800, 200); background(255); } void draw() { int i=0; while (i<10){ if(millis() - time >= wait
int time;
int wait =1000;
void setup()
{
time = millis();
size(800, 200);
background(255);
}
void draw() {
int i=0;
while (i<10){
if(millis() - time >= wait){
time = millis();
}
translate(60, 0);
rect(0, 0, 10, 10);
}
}
int时间;
int wait=1000;
无效设置()
{
时间=毫秒();
大小(800200);
背景(255);
}
作废提款(){
int i=0;
while(i=等待){
时间=毫秒();
}
翻译(60,0);
rect(0,0,10,10);
}
}
发生这种情况是因为您正在阻止draw()函数完成。通过设置一个整数i=0,然后说while(i,正如@Petros所提到的,你进入了无限循环,但是使用delay()
int wait = 1000;
int translate = 0;
int count = 0;
void setup()
{
size(800, 200);
background(255);
}
void draw() {
if(count < 10)
{
delay(wait);
translate += 60;
translate(translate, 0);
rect(0, 0, 10, 10);
count++;
}
}
它就像一个符咒,谢谢,但它没有达到我的预期。如果我将If语句中的计数值更改为20,它将超出窗口。如果我将translate语句中的0与count变量交换,我希望看到最后一个矩形在每次绘制后继续向下移动1。如果它没有,那是因为我没有移动吗窗口,但只有网格?以及如何做到这一点?稍后,recht应该是一个数据流,我需要查看窗口中的最后一个条目。很抱歉没有指定此需求。已更新!如果需要其他内容,您还应该编辑您的问题。
int wait = 1000;
int translate = 0;
int count = 0;
void setup()
{
size(800, 200);
background(255);
}
void draw() {
if(count < 10)
{
delay(wait);
translate += 60;
translate(translate, 0);
rect(0, 0, 10, 10);
count++;
}
}
int wait = 100;
int translate = 0;
int count = 0;
static final int MAX = 10;
void setup()
{
size(60*MAX, 12*MAX);
background(255);
}
void draw() {
if(count < MAX)
{
delay(wait);
translate(translate, count*11);
translate += 60;
rect(0, 0, 10, 10);
fill(50);
text("Data", 15, 10);
noFill();
count++;
}
}