Im creating a game which is basically a target practise game which will have multiple balls on the screen and you click on them and they will disappear.
My problem is that I want the program to end the game if the green ball is hit. When I use system.exit(abort) it closes the whole program but I just want it to end the game and call the ending frame.
any help would be appreciated.
Code below : this.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e);
for (Ball ball : balls) {
if ((new Ellipse2D.Double(ball.positionX, ball.positionY, ball.size, ball.size))
.contains(e.getPoint())) {
clicksLandedOnABall++;
if (ball.ballColour == Color.GREEN)
{
}
ball.ballColour = Color.WHITE;
}
}
}
});
}
Aucun commentaire:
Enregistrer un commentaire