我正在用 Java 编写游戏 Breakout。我的背景一开始是灰色的,但当我获胜时,我希望它变成绿色。但是,我无法做到这一点。有人可以帮助我吗?
这里声明了颜色;
// Those are the basic statements and properties of the game and prepares the game to start
int numberlost =0;
Graphics gContext;
Image buffer;
Thread thread;
boolean leftArrow = false;
boolean rightArrow = false;
boolean ballready = true;
boolean extraball=false;
Ball ball;
Field brick;
Paddle paddle;
public static final Color
PaddleColor=Color.black,
ObstacleColor=Color.red,
BallColor=Color.red;
public static Color FieldColor = new Color(0xcccccc); // background is hexidemal color grey
这是我的 win() 方法:
// This method is called when you win
public void win() {
ball=null;
paddle=null;
// the background is set to green
FieldColor= Color.green;
}