Java Swing实现Flappy Bird时下管道图形异常问题求助
Flappy Bird下管道显示异常问题求助

以下是使用Java Swing JPanel实现的图形显示部分代码:
public void paintComponent(Graphics g) { super.paintComponent(g); // Draw background image backgroundImage.paintIcon(this, g, 0, 0); // Draw obstacles for (Rectangle obstacle : obstacles) { int pipeSpace = space; // space between upper and lower pipes int lowerPipeHeight = 600 - obstacle.height - pipeSpace; // Draw lower pipe g.drawImage(lowerPipeIcon.getImage(), obstacle.x, obstacle.y + obstacle.height + pipeSpace, obstacle.width, lowerPipeHeight, this); // Draw upper pipe g.drawImage(upperPipeIcon.getImage(), obstacle.x, obstacle.y, obstacle.width, obstacle.height, this); } }
下管道始终显示异常,我尝试过多种修改代码的方法,但问题反而变得更糟。游戏核心代码大多在Launcher和FlappyBird文件中,恳请技术大佬帮忙解决这一棘手问题。
内容的提问来源于stack exchange,提问作者Joshi Minh
相关产品推荐
相关产品推荐

