Java 当用户丢失时,如何隐藏其他图像?

Java 当用户丢失时,如何隐藏其他图像?,java,processing,Java,Processing,我正在制作一个flappy bird游戏,在我的代码中,如果鸟与管道碰撞,我会制作它,如果它与管道碰撞,它会在屏幕上显示一个游戏。它正确地显示了屏幕,但仍然在gameover屏幕的顶部显示管道和鸟,我尝试使用boolean showimage=false,但这似乎不起作用,任何指导都将不胜感激 我还没有添加它,所以当用户死亡时游戏停止,我想这可能是原因之一 编辑:看来我不是很清楚,所以我道歉。我问的是,当鸟与管道碰撞时,如何仅显示gameover屏幕(isCollide),但是,它当前在game

我正在制作一个flappy bird游戏,在我的代码中,如果鸟与管道碰撞,我会制作它,如果它与管道碰撞,它会在屏幕上显示一个游戏。它正确地显示了屏幕,但仍然在gameover屏幕的顶部显示管道和鸟,我尝试使用
boolean showimage=false
,但这似乎不起作用,任何指导都将不胜感激

我还没有添加它,所以当用户死亡时游戏停止,我想这可能是原因之一

编辑:看来我不是很清楚,所以我道歉。我问的是,当鸟与管道碰撞时,如何仅显示gameover屏幕(
isCollide
),但是,它当前在gameover屏幕上方显示管道和鸟,我问的是如何隐藏鸟和管道,仅显示gameover屏幕

这是我的游戏代码,与我的问题有关,完整的代码可以在前面的编辑中找到

import processing.serial.*;
PImage gameover;
PImage bg; //Declaring variables for images
PImage img;
PImage imgPipe;
Serial myPort;

void isCollide(Pipe myP) {
 if ((x + size > myP.pipeX) && (x < myP.pipeX + myP.pipeWidth) && (y <
   myP.upperBound)) {
  image(gameover, 0, 0);
 }

 if ((x + size > myP.pipeX) && (x < myP.pipeX + myP.pipeWidth) && (y + size >
   myP.lowerBound)) {
  image(gameover, 0, 0);
 }
}

void display() {
 pushMatrix();
 translate(x, y);
 fill(255);
 image(img, 0, 0, size, size);
 popMatrix();
}

void display() {
 stroke(0);
 fill(120, 90, 55);
 image(imgPipe, pipeX, upperBound - imgPipe.height); //Upper pipe image
 image(imgPipe, pipeX, lowerBound); //Lower Pipe image
}

void setup() {
 myPort = new Serial(this, Serial.list()[3], 9600); //Port the Arduino is 
 plugged into
 size(300, 500);
 bg = loadImage("background2.jpg"); //Loading images
 img = loadImage("bird.png");
 imgPipe = loadImage("wall2.png");
 myBird = new Bird();
 myPipe.renew();
 gameover = loadImage("gameover.png");
}

void draw() {
 background(bg); //Drawing background
 myPipe.update();
 myBird.control();
 myBird.isCollide(myPipe);

 myBird.display();
 myPipe.display();
}
import processing.serial.*;
皮迈格·加莫弗;
皮马杰bg//为图像声明变量
皮马杰;
PImage IMG管道;
串行端口;
空心夹层(管道myP){
如果((x+尺寸>myP.pipeX)和&(xmyP.pipeX)和((x
myP.lowerBound){
图像(gameover,0,0);
}
}
无效显示(){
pushMatrix();
翻译(x,y);
填充(255);
图像(img,0,0,大小,大小);
popMatrix();
}
无效显示(){
冲程(0);
填充(120、90、55);
图像(imgPipe,pipeX,上限-imgPipe.height);//上部管道图像
图像(imgPipe、pipeX、lowerBound);//下部管道图像
}
无效设置(){
myPort=new Serial(这个,Serial.list()[3],9600);//Arduino的端口是
插入
大小(300500);
bg=loadImage(“background2.jpg”);//正在加载图像
img=loadImage(“bird.png”);
imgPipe=loadImage(“wall2.png”);
myBird=新鸟();
myPipe.renew();
gameover=loadImage(“gameover.png”);
}
作废提款(){
背景(bg);//绘图背景
myPipe.update();
myBird.control();
myBird.isCollide(myPipe);
myBird.display();
myPipe.display();
}

需要我们为您调试的代码太多了。特别是因为我们甚至不能运行它,因为我们没有串行设备。你能不能把它缩小到一个我们可以复制粘贴自己运行的范围?@KevinWorkman嗨,我不确定我能不能为你做一个副本,因为我是用arduino作为控制器制作的,我可以更新它来显示相关的代码片段,尽管每当发生冲突时,调用
noLoop()
,并确保屏幕上的游戏是您在
draw()
@MasterYushi()中绘制的最后一个东西。noLoop()结束了游戏,但是图像仍然显示在gameover图像上?这就像它扮演一个角色bg@AdamSteele你的问题是关于隐藏图像,而不是关于Arduino。对于显示问题的示例,您可以只使用在按键时隐藏的硬编码图像。