# AS3 - Increase tint as health decreases

I'm working on a game where enemies continually spawn with more and more health based on how long you've been playing. As the enemies take damage, I'd like their sprite to get darker and darker, until they die.

Here's what I've got so far:

    enemy_array[i].health -= damage;
healthcolor.setTint(0x000000, enemy_array[i].health*0.1);
enemy_array[i].transform.colorTransform = healthcolor;


Predictably, this is making enemies get less black as they take damage. What I need is to convert the decreasing enemies' health into an increasing number between 0 and 1.

I have absolutely no idea where to begin. It's entirely possible I have tunnel vision, but I'm hoping someone here might have an idea for how to accomplish this.

Thanks for your time.

## 1 Answer

A friend of mine actually provided a great solution on Facebook.

Healthratio = currentHealth/MaxHealth
tintRatio = 1.0 - healthratio


Anyway, I wanted to share that in the off chance anyone ever has a similar problem and wants a quick solution. Shout out to @keirmiron for that.