mousePressed()가 3 초마다 false 일 때 화면에 텍스트 표시를 만들고 싶습니다. mousePressed() 함수에서 "여부"를 부울로 설정하고 문자열을 false로 만들면 문자열을 가져옵니다. 텍스트 파일에서. 하지만 내 논리가 잘못된 것처럼 보입니다. 문제를 아는 사람이 있습니까?mousePressed()가 거짓 일 때 텍스트 추가
Zoog[]zoog = new Zoog[1];
float count=0;
int xpos =0;
int ypos =0;
String message="haha";
String newone="";
String t="\n";
int ntextsize = 20;
int nopacity =200;
int thistime = 0;
int thiscount = 0;
String[]lines;
//Zoog zoog;
boolean whether;
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();
}
whether = false;
lines = loadStrings("data.txt");
if(whether!=true){
createnew(int(random(width)), int(random(height)), lines[int(random(lines.length))],150);
}
}
void mousePressed(){
whether = true;
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;
}
nopacity = int(random(100,255));
createnew(xpos,ypos,message,nopacity);
}
void createnew(int xxpos, int yyos, String mmessage, int nnopacity){
Zoog b = new Zoog(xpos,ypos,message,nopacity);
zoog =(Zoog[]) append(zoog,b);
}
내 질문에 해당하는 기능은 다음과 같습니다
lines = loadStrings("data.txt");
if(whether!=true){
createnew(int(random(width)), int(random(height)), lines[int(random(lines.length))],150);
}
}
및
void createnew(int xxpos, int yyos, String mmessage, int nnopacity){
Zoog b = new Zoog(xpos,ypos,message,nopacity);
zoog =(Zoog[]) append(zoog,b);
}
하지,하지만 당신은해야 설치()에서 텍스트 파일을 한 번로드하십시오. –