2012-07-25 5 views
1

Slick에서 상태 표시 줄을 렌더링하려고합니다. 나는 그 앞에 녹색이있는 빨간색 직사각형으로 건강 상태를 보여주고 싶다.Slick - 채워진 직사각형

 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); 

이 화면에 렌더링되는 것입니다 :

Screenshot of health bar in action

답변

2

문제는 잘못된 렌더링 방법을 사용하는 것입니다 이것은 내가 지금까지있는 것입니다. Graphics에는 draw() 및 fill()의 두 가지 유형이 있습니다. 귀하의 렌더링 행은 다음과 같습니다

float healthGAWidth = ((float) health/(float) maxHealth) * (float) healthWidth; 
g.fillRect(healthX, healthY, healthWidth, healthHeight); 
g.fillRect(healthX, healthY, healthGAWidth, healthHeight); 
: 그래픽 작성 직사각형하는 방법이 있기 때문에

g.fill(healthBG, healthFill); 

은 또는 당신은 사각형 또는 ShapeFill을 건너 뛸 수

관련 문제