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);
這就是在屏幕上呈現: