1
我想呈现一个健康酒吧与油滑。我想要一个红色的长方形,前面有一个绿色的矩形,以显示剩余的健康状况。这是我到目前为止有:油滑 - 填充矩形
Rectangle healthBG = new Rectangle(healthX, healthY, healthWidth, healthHeight);
ShapeFill healthFill = new GradientFill(0, healthHeight/2, Color.red, healthWidth, healthHeight - 1, Color.orange, true);
float healthGAWidth = ((float) health/(float) maxHealth) * (float) healthWidth;
Rectangle healthGA = new Rectangle(healthX, healthY, healthGAWidth, healthHeight);
ShapeFill healthGAFill = new GradientFill(0, healthHeight/2, Color.green, healthGAWidth, healthHeight - 1, Color.green, true);
//g.setColor(Color.red);
g.draw(healthBG, healthFill);
//g.setColor(Color.green);
g.draw(healthGA, healthGAFill);
这就是在屏幕上呈现: