所以我做了一个健康栏,它会根据个人的健康状况改变颜色。但是我想让它当玩家走到血条下方时,它会变成半透明的,我想知道如果血条是由 HSB 颜色制成的,我该怎么做?
private static float HEALTH = 100;
public void render(Graphics g) {
g.setColor(Color.GRAY);
g.fillRect(15, 15, 200, 32);
color = Color.getHSBColor( (1f * HEALTH) / 360, 1f, 1f);
g.setColor(Color.getHSBColor( (1f * HEALTH) / 360, 1f, 1f));
g.fillRect(15, 15, (int) HEALTH * 2, 32);
g.setColor(Color.white);
g.drawRect(15, 15, 200, 32);
}