1
所以,我想知道是否有辦法讓文本出現,然後消失,因爲它被替換爲不同的文本。我目前發現了一個代碼,可以讓我逐一緩慢地顯示文本,但是我不知道代碼能讓我在新文本出現時擺脫先前的文本。請幫幫我!要做到這一點使文本在處理中出現並消失
// creates the window with white background
import ddf.minim.*;
Minim minim;
AudioSnippet snip;
color c1 = color(0,0,0), c2 = color(0,0,0), current;
void setup(){
size(1200, 800);
current = c1;
smooth();
minim = new Minim(this);
snip = minim.loadSnippet("LoudGun.mp3");
}
void mousePressed() {
snip.play();
if(current==c1) { current = c2; } else { current = c1; }
}
// draw "Charlotte"
void CharlotteBacon() {
frameRate(5);
fill(255);
textSize(50);
text("Charlotte Bacon, Age 6", 600, 275);
}
// draw "Daniel"
void DanielBarden() {
frameRate(5);
fill(255);
textSize(50);
text("Daniel Barden, Age 7", 20, 50);
}
int col = 0;
// main method where all above methods are executed on the white window
void draw() {
background(current);
if(mouseX != pmouseX && mouseY != pmouseY){
}
if (mousePressed) {
}
// each phrase is printed at intervals of 2 seconds
if (mouseX == pmouseX && mouseY == pmouseY && mousePressed != true) {
;
int currentTime = millis();
int timeLapse = 2000;
if (currentTime > timeLapse) {
CharlotteBacon();
}
if (currentTime > timeLapse*2) {
DanielBarden();
}
}
}
非常感謝你!這很棒! – user2337815 2013-05-06 05:57:06