both maxHealth and m_playerHealth is an int
...
oh that actually worked though, mind explaining the static_cast<float> ?
It doesn't seem like you understood marcjulian, so I'll try to rephrase it in a different manner:
The function "setScale" takes floats. If you try to do this: int health = 50 / 100;
You're not going to get 0.5, because an integer can only be whole numbers. So that is: 0, 1, 2, 3, 4, 5, 6...
Also, you could make a "healthRatio" function, like this:
float healthRatio() {
return (float) m_playerHealth / (float) maxHealth;
}
healthBarSprite.setScale(healthRatio(), 1.0f);
I recommend reading marcjulian's post a few more times until you get it.