【发布时间】:2021-10-16 17:27:00
【问题描述】:
我想设置一个游戏。
当我按下“s”键,然后开始游戏。 在我按下鼠标右键后, 它将重置并停止游戏。 现在的问题是当我单击鼠标右键时, 变量“game”应该设置为false, 但是当我释放鼠标按钮时它仍然是正确的。
有人可以帮助我吗?谢谢。
boolean game = false;
void setup() {
size(640, 480);
}
void draw() {
background(200, 200, 200);
if (key=='s') game=true;
println("1::" + game);
if (game==true) {
// gaming...
if (mousePressed && mouseButton == RIGHT) {
// I want to reset the game...
game=false;
println("2 after pressed right mouse button::" + game);
}
println("3 why still run the code here after I press mouse right button? ");
}
}
void mouseDragged()
{
if (game==true) {
// the dragging game...
print("3:: dragging" + game);
}
}
【问题讨论】:
标签: processing