이 그룹의 마지막 배열이 추가 될 때까지 어레이 그룹이 페이드 아웃되게하고 싶습니다. 예를 들어, 나는 zoog [0], zoog [1], zoog [2]를 만들기 위해 append를 사용하고, zoog [2]가 생성 될 때까지이 세 객체를 fadeout하지 않고 잠시 기다려야한다. 3], zoog [4], zoog [5]와 같이이 세 객체는 zoog [5]가 생성 될 때까지 fadeout되지 않습니다. 그러나 이제 내가 할 수있는 것은 각 객체가 생성되는 즉시 페이드 아웃을 만드는 것입니다.마지막 배열이 추가 될 때까지 텍스트 배열이 사라지지 않습니다.
Zoog[]zoog = new Zoog[1];
float count=0;
int xpos =0;
int ypos =0;
String message="haha";
int ntextsize = 20;
int nopacity =200;
int thistime = 0;
int thiscount = 0;
//Zoog zoog;
void setup() {
size(400, 400);
xpos = int(random(width/2-200, width/2+40));
ypos = int(random(height/2, height/2-40));
zoog[0] = new Zoog(xpos,ypos,message,nopacity);
}
void draw(){
background(255,255,255);
for(int i=0; i<zoog.length; i++){
// if(millis()-thistime>4000){
// zoog[i].disappear();
// }
zoog[i].jiggle();
zoog[i].display();
}
}
void mousePressed(){
count = count + 1;
// int thiscount = 0;
if(count%3 ==0){
xpos=int(random(30, width-30));
ypos=int(random(10, height-10));
}
else{
ypos = ypos+50;
// thiscount = thiscount +1;
// thistime = millis();
// }
}
nopacity = int(random(100,255));
// text(message, xpos, ypos);
Zoog b = new Zoog(xpos,ypos,message,nopacity);
zoog =(Zoog[]) append(zoog,b);
}
난 당신이 3 zoogs을하고 그들이 사라지고있어 아웃 할 때까지 그 세 페이딩 시작하려면 제대로 이해하고 Zoog 클래스
class Zoog {
int x;
int y;
String thatmessage;
int opaci =0;
Zoog(int xpo, int ypo, String thismessage, int opa) {
x = xpo;
y = ypo;
thatmessage = thismessage;
opaci = opa;
}
void jiggle() {
x = x+int(random(-2, 2));
y = y+int(random(-2, 2));
}
void display() {
fill(0, opaci);
text(thatmessage, x, y);
print("x position is "+ x);
print("y position is "+y);
}
void disappear() {
for (int j=0; j<255; j++) {
opaci = opaci -j;
}
}
}
다른 배열을 설치해야하는 것처럼 보입니다 – Douuga
추가하지 말고 ArrayList를 사용해야합니까? – Douuga
문제는 Zoog [0], Zoog [1], Zoog [2]가 Zoog [2]가 생성 될 때만 함께 사라지 길 원합니다. – Douuga