我刚刚让一个物体连续移动,现在我想让它在10秒内停止,如果按下空格键?
有人知道如何在处理过程中实现这一点吗?谢谢你的进阶!
发布于 2022-10-13 21:37:31
默认情况下,处理以每秒60帧的速度绘制,因此您可以将其用于您的优势。
//Global Variables
int countDownTimer = 600 //10 seconds * 60 FPS
boolean spacePressed = false;
void draw(){
if(spacePressed){
countDownTimer--;
if(countDownTimer == 0){
//Whatever happens after 10 seconds here
}
}
}
void keyPressed(){
if(key == " "){
spacePressed = true;
}
}https://stackoverflow.com/questions/74053988
复制相似问题