This is how I use it
void character::Dec_Life(int Damage,sf::Sprite& Lifebar)
{
m_life -= Damage;
Lifebar.SetSubRect(sf::IntRect(0,0,95, m_life / m_max_life * 190));
Lifebar.Move(0, (768 - 190 + ( 190 - (m_life / m_max_life * 190))));
}
m_life is an integer that represents the life. m_max_life is the maximum life you can have.