Hello, I've made a HealthCounter class for making hp bar and I have two players in my game. My first player's hp bar was fine with decreasing health from the right side but I want the second player's hp bar to decrease from the left side. How can I make it ?
Here is my code for making hp bar. For your information Thank you (:
public class HealthCounter extends Actor
{
int health = 180;
int healthBarWidth = 180;
int healthBarHeight = 16;
GreenfootImage hp;
public void act()
{
update();
}
public void update(){
setImage(new GreenfootImage(healthBarWidth + 2,healthBarHeight + 2));
hp = getImage();
hp.setColor(Color.WHITE);
hp.drawRect(0, 0, healthBarWidth + 1, healthBarHeight + 1);
//when health is less than 80, become red.
if(health < 80){
hp.setColor(Color.RED);
} else{ //the default color is green
hp.setColor(Color.GREEN);
}
hp.fillRect(1, 1, health, healthBarHeight);
}
public void loseHealth(){
health = health - 10;
}
}


