if you press "R" the amount should go up by 1, but if you press "R" when the program is 'waiting' it should not detect the input. But with delay and sleep the program keeps track of the input and does the input after the delay. Is there any function to wait and not gaining any input?
import java.util.concurrent.TimeUnit;
int amount;
void setup()
{
size(200, 200);
}
void draw()
{
background(#FEF4E9);
fill(#FF0000);
if (key == 'r'){
//delay(500);
try{
Thread.sleep(500);
}catch(InterruptedException e){
System.out.println("got interrupted!");
}
amount++;
println("amount: "+amount);
}
}
Aucun commentaire:
Enregistrer un commentaire